So I have this XP script that is given to players whether they're in a group or not. Now the thing is, I don't know if it's the debounce that ruins it, or the previous code that's being said, but here take a look. It works right when I try it out in Server Mode, but after a while, it stops working.
local debounce = false players = game:FindService("Players") repeat wait() until players ~= nil whatever = game.Workspace script.Parent.Touched:connect(function(hit) if debounce then return end debounce = true local character = hit.Parent if character.ClassName == "Accessory" then if character.Parent == whatever then character:Destroy() wait() else wait() end if character.ClassName == "RopeConstraint" or "Attachment" then wait() end print("Debounce Set to True") --this doesn't pop up when the script breaks or stops working-- elseif hit.Name == "Handle" and hit.Parent:IsA("Tool") then print("Ball has been found") local Ball = hit print("Local Ball changed to hit") local BallHandlerVal = Ball.Parent:WaitForChild("BallHandler") print("BallHandlerVal has been found") repeat wait() until BallHandlerVal ~= nil local BallHandler = players:FindFirstChild(BallHandlerVal.Value) print("BallHandler has been found") local cash = BallHandler:FindFirstChild("leaderstats") print("cash has been found") if BallHandler and cash then print("BallHandler and Cash successful") local EXPValue = cash:WaitForChild('XP') print("XP has been found") if BallHandler:IsInGroup(3164314) then print("Player is in Group") EXPValue.Value = EXPValue.Value + 20 print("Gave Group EXP") else print("Player is not in Group") EXPValue.Value = EXPValue.Value + 10 print("Gave Reg EXP") end end wait(1) print("Debounce Set to False") debounce = false end end)
These scripts are held inside a model, inside a part, all under workspace.
In-Depth to Least Depth: XP Script -> Part -> Model -> Workspace
Hopefully you guys can solve the problem,if not I'd be glad to show you how it's breaking.
-LukeGabrieI
-- Line 19 if character.ClassName == "RopeConstraint" or character.ClassName == "Attachment" then --changes here? wait() end print("Debounce Set to True")