When I have my code in this format, it doesnt work. However if i take out the if condition for checking that the value is 0 it works. Im not sure why, hopefully one of you lovely people can figure it out
ticket = script.Parent
debounce = 0
function onTouched(hit)
if debounce == 0 then
debounce = 1
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:FindFirstChild("orbfolder")
if stats ~= nil then
local ticket = stats:FindFirstChild("orb1")
if ticket.Value == 0 then
ticket.Value = ticket.Value + 1
wait(5)
debounce = 0
end
else
end
end
end
end
ticket.Touched:Connect(onTouched)

3 comments
So basically, your function only works if they have no tickets. Oh and about the Boolean debounces, its just easier to read that way. Really nothing wrong with what you were doing.
It worked now when i copied and pasted what i put in here to there. Weird.
Glad to help