Currently, I’m busy making a new game that includes RGB ceiling lights. Now, I’m not going to provide details of the game as I want to keep it exclusively secretive until I announce it, however I wanted to charge players Robux for using this feature for various reasons (this may change but for now this is the case).
I’ve written all the scripts by myself with little help from the Internet, which is a great thing for me. I have no issues at all writing a script that turns on a light via ProximityPrompts, it’s just adding in that “pay to use” function that I’m having trouble with.
local RGB1 = script.Parent.RGB1 local RGB2 = script.Parent.RGB2 local SurfaceLight = RGB1.SurfaceLight local ProximityPrompt = script.Parent.RGBSwitch.ProximityPrompt local id = 135483662 local Bool = true --ProximityPrompt.Triggered:Connect(function() -- if Bool == true then -- RGB1.SurfaceLight.Enabled = false -- RGB1.Transparency = 1 -- RGB2.SurfaceLight.Enabled = false -- RGB2.Transparency = 1 -- Bool = false -- elseif Bool == false then -- RGB1.SurfaceLight.Enabled = true -- RGB1.Transparency = 0 -- RGB2.SurfaceLight.Enabled = true -- RGB2.Transparency = 0 -- Bool = true -- end --end) ----------- game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and id == ido then ProximityPrompt.Triggered:Connect(function() if Bool == true then RGB1.SurfaceLight.Enabled = false RGB1.Transparency = 1 RGB2.SurfaceLight.Enabled = false RGB2.Transparency = 1 Bool = false end end) game.Players.PlayerAdded:Connect(function(plr) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then elseif Bool == false then RGB1.SurfaceLight.Enabled = true RGB1.Transparency = 0 RGB2.SurfaceLight.Enabled = true RGB2.Transparency = 0 Bool = true end end)
Important to Note
- The commented code works but the user is not required to pay to use the RGB feature.
- I’ve duplicated the code and tried to add in a gamepass purchase, which is where my issue lies.
- If for whatever reason this doesn’t work out, I can always use the previous code! This way I won’t have to start over and it makes it easy for members here on CT to read the code.
- I plan to recycle the new code for a jukebox music system at some point, if I can resolve this problem.