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

How can I make my Local Player Script work?

Asked by
NecoBoss 194
10 years ago

Please tell me what is wrong with this script. I also want to know how to make the TextButton not visable.

function onClick()
    while true do
        game.Players.LocalPlayer.leaderstats.Score.Value = game.Players.LocalPlayer.leaderstats.Score.Value + 1

        local str =  game.Players.LocalPlayer.leaderstats.Score.Value
        local str1 = "Your income: "
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text = str1..str
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextButton.Visable = false      
wait(1)
    end
end

script.Parent.TextButton.MouseButton1Click:connect(onClick)

1 answer

Log in to vote
0
Answered by 10 years ago

There is this weird thing for local scripts, that you have to put wait(0.1) at beginning of the code. You might be able to use smaller wait time, but I haven't experimented with it too much, so I stick to using 0.1 seconds.

0
Oh really? Okay. NecoBoss 194 — 10y
0
Yeah, essentially it has something to do with script loading faster than GUI objects, so it errors. It's kind of silly. ZarsBranchkin 885 — 10y
Ad

Answer this question