Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by 6 years ago

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

0
Why are you checking if the character is an accessory? The class of a character will always be a model. RayCurse 1518 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago
-- Line 19
if character.ClassName == "RopeConstraint" or character.ClassName == "Attachment" then --changes here?
        wait()
    end
        print("Debounce Set to True")
0
:( User#17685 0 — 6y
0
wait what lol LukeGabrieI 73 — 6y
0
' "RopeConstraint" or "Attachment" ' . < You sure you could do that? , -.- User#17685 0 — 6y
0
Been studying different programming language. -.- User#17685 0 — 6y
Ad

Answer this question