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

Why isn't the ForceField destroying?

Asked by 9 years ago

This script is inside of a TextButton. When you click the button you're supposed to lose 1000 points and have a ForceField around you for one second, then the ForceField Destroys.

The problem is after i lose my points and wait one second, the ForceField doesn't destroy.

script.Parent.MouseButton1Click:connect(function()
    if game.Players.LocalPlayer.Points.Value > 999 then
        local ff = game.Players.LocalPlayer.Character:FindFirstChild("ForceField")
        if not ff then
            local f = Instance.new("ForceField",game.Players.LocalPlayer.Character)
            game.Players.LocalPlayer.Points.Value = game.Players.LocalPlayer.Points.Value - 1000
            wait(1)
            print 'waited'
            if ff then
                print 'rip'
                ff:Destroy()
            end
        end
    end
end)
0
line 9 (When fixed by the answer given) doesn't seem necessary unless somehow the ForceField will vanish in another way. You should just switch 9 out with "f:Destroy()" then where f:Destroy was before change alphawolvess 1784 — 9y
0
Well yeah but what if you reset? Senor_Chung 210 — 9y

1 answer

Log in to vote
0
Answered by
SurVur 86
9 years ago

I think you made a typo

script.Parent.MouseButton1Click:connect(function()
    if game.Players.LocalPlayer.Points.Value > 999 then
        local ff = game.Players.LocalPlayer.Character:FindFirstChild("ForceField")
        if not ff then
            local f = Instance.new("ForceField",game.Players.LocalPlayer.Character)
            game.Players.LocalPlayer.Points.Value = game.Players.LocalPlayer.Points.Value - 1000
            wait(1)
            print 'waited'
        --right here
            if f then
                print 'rip'
                f:Destroy()
            end
        end
    end
end)

0
I did make a typo. Thanks! Senor_Chung 210 — 9y
Ad

Answer this question