Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?)

4 comments

0

Is this a script or localscript?

0

A script

0

Thx

0

if not toolClicked?

1 answer

✓ Accepted answer

game.Players.LocalPlayer is only accessible by a localscript. As this script deals with money, I would suggest you use a seperate localscript that would deal with input and forward that information to this script with a RemoteEvent so 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.

1 comment

0

I just removed the normal script and added the localscript and it seems to work well now.

This discussion is preserved as it was. New answers, comments, and votes are closed.