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

Is my scripting correct? (I believe it is but for some reason it isn't working look

Asked by 6 years ago
local toolClicked = false 

Player = game.Players.LocalPlayer
local tool = script.Parent


tool.Activated:connect(function()
    if not toolClicked then

        toolClicked = true
wait(1.2)
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 3
toolClicked = false


    end
    end)

So this works in the studio when I press play but when I use ROBLOX Player instead it won't work. (won't give any cash, so can someone help?)

0
Is this a script or localscript? lukeb50 631 — 6y
0
A script JohnerDev 27 — 6y
0
Thx JohnerDev 27 — 6y
0
if not toolClicked? greatneil80 2647 — 6y

1 answer

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
6 years ago

game.Players.LocalPlayer is only accessible by a localscript. As this script deals with money, I would suggest you use a seperate localscriptthat would deal with input and forward that information to this script with a RemoteEventso it can add the money.

The reason this works in studio is because studio does not differentiate between the two kinds of scripts well but the game client does.

0
I just removed the normal script and added the localscript and it seems to work well now. JohnerDev 27 — 6y
Ad

Answer this question