Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

XP Script Temporarily Works? Stops Working After Period of Time?

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

1 comment

0

Why are you checking if the character is an accessory? The class of a character will always be a model.

1 answer

-- Line 19
if character.ClassName == "RopeConstraint" or character.ClassName == "Attachment" then --changes here?
        wait()
    end
        print("Debounce Set to True")

4 comments

0

:(

0

wait what lol

0

' "RopeConstraint" or "Attachment" ' . < You sure you could do that? , -.-

0

Been studying different programming language. -.-

This discussion is preserved as it was. New answers, comments, and votes are closed.