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 7 years ago
01local toolClicked = false
02 
03Player = game.Players.LocalPlayer
04local tool = script.Parent
05 
06 
07tool.Activated:connect(function()
08    if not toolClicked then
09 
10        toolClicked = true
11wait(1.2)
12Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 3
13toolClicked = false
14 
15 
16    end
17    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 — 7y
0
A script JohnerDev 27 — 7y
0
Thx JohnerDev 27 — 7y
0
if not toolClicked? greatneil80 2647 — 7y

1 answer

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
7 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 — 7y
Ad

Answer this question