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

Why does this script work in studio but not in-game?

Asked by 9 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

This script is supposed to give you a ForceField when you click the text button when you have over 1000 points. I have 100,000 points but I don't get a ForceField, I don't lose any points either.

chr = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()

script.Parent.MouseButton1Down:connect(function()
    print 'clicked'
    if game.Players.LocalPlayer.Points.Value > 999 then
    print 'Points are enough'
    local points = game.Players.LocalPlayer:WaitForChild("Points")
    local rl = chr:WaitForChild("RocksLeft")
    print 'loaded everything'
        if rl.Value < 15 then
            print 'cloned'
            points.Value = points.Value - 1000
            script.Parent.Parent.Balance.Text = "Points: "..game.Players.LocalPlayer.Points.Value
            local f = Instance.new("ForceField",game.Players.LocalPlayer.Character)
            rl.Value = 15
        end
    end
end)

No errors or anything in the output either.

EDIT I've tested it a few times and it won't print 'loaded everything'

I don't know how to fix this so please help.

0
Is it a localscript? NotsoPenguin 705 — 9y
0
Yeah Senor_Chung 210 — 9y
0
I think the problem is it's not loading points or rl. Senor_Chung 210 — 9y
0
Your conclusion makes sense to me (*if* "Points are enough" is getting printed out). I recommend debugging the scripts responsible for creating "Points" or "RocksLeft". Also, you access ".Points" (line 5) before using "WaitForChild" (line 7). chess123mate 5873 — 9y
0
I need a bit more information. What is "RocksLeft" suppose to be? Also, there's no point in using :WaitForChild("Points") in line 7 because if line 5 worked, "Points" has already been found. alphawolvess 1784 — 9y

Answer this question