I wrote this script, it's on touch. If the player touches and owns game pass with leaderstats greater than or equal to 666 then, change the color of fire inside each part of character. I don't know why it doesn't work sometimes though and, I can't seem to get any output. I don't know how else to describe it or ask the question but, what seems to be the problem? It's only working once if the player owns the gamepass if not then not at all. If you could, can you please explain the problem and provide any links if needed? I appreciate the help. Sorry I've been asking so many questions lately! Thank you in advance as always.
Code I'm using is a Script inside of a Part inside of Workspace.
local debounce = true local MarketplaceService = game:GetService("MarketplaceService") local GamepassId = 17468467--my gamepassid script.Parent.Touched:Connect(function(hit) if debounce == true and hit.Parent:FindFirstChild("Humanoid") then debounce = false local character = hit.Parent local player = game:GetService("Players"):GetPlayerFromCharacter(character) if player and MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) and player.leaderstats.Tix.Value >= 666 then local avatar = character:GetChildren() for _,t in pairs(avatar) do if t.ClassName == "Part" then local fire = t.Fire fire.Color = Color3.new(1,0,0) fire.SecondaryColor = Color3.new(0,0,0) end end end wait(1) end end)
You didn't set debounce back to true.
if debounce == true and hit.Parent:FindFirstChild("Humanoid") then debounce = false local character = hit.Parent local player = game:GetService("Players"):GetPlayerFromCharacter(character) if player and MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) and player.leaderstats.Tix.Value >= 666 then local avatar = character:GetChildren() for _,t in pairs(avatar) do if t.ClassName == "Part" then local fire = t.Fire fire.Color = Color3.new(1,0,0) fire.SecondaryColor = Color3.new(0,0,0) end end end wait(1) debounce = true end