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

Shop code that was working isn't working anymore?

Asked by
R_alatch 394 Moderation Voter
8 years ago

I was using this code, and now it isn't working anymore. I don't get an error either. Help?

debounce = false

script.Parent.Touched:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    local leaderstats = player:WaitForChild("leaderstats")
    local cash = leaderstats:WaitForChild("Cash")
    local amount = 5
    local weapon = game.ServerStorage:WaitForChild("LinkedSword")

    if not debounce then
        debounce = true
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health > 0 then
            if leaderstats and cash and cash.Value >= amount then
                cash.Value = cash.Value - amount

                local weaponclone = weapon:Clone()
                weaponclone.Parent = player.Backpack

                local weaponclone = weapon:Clone()
                weaponclone.Parent = player.StarterGear

                wait(2)
                debounce = false
            end
        end
    end
end)
0
Try turning FilteringEnabled off. TheHospitalDev 1134 — 8y
0
Please help us help you. Tell us what type of script, where it is located, the expected behaviour, the actual behaviour, and whether filtering/streaming are enabled. User#6546 35 — 8y
0
You should move that "debounce = false" down to the previous if statement. In the case that something non-player touches it, it'll break forever joalars2 107 — 8y
0
A lot of the time when I have a script that was working before but then stops working is cause of the variables not being found, and the output won't print an error, cause you're script will keep looking for it. I would suggest adding prints on every few lines to see where the script stops working NinjoOnline 1146 — 8y

Answer this question