i have a tool and i am trying to add +1 money every time i click with tool how do i make that happen
1 | local money = game.Players.LocalPlayer.LeaderBoard.Money.Value |
2 | local tool = game.StarterPack.Tool |
It's because the StarterPack is only the folder where tools will be given to the player when they join the game or respawn.
Possible fix: Insert a normal script into the tool. Type in this code:
01 | local tool = script.Parent -- Defining the tool. |
02 | cooldown = false -- Making the cooldown variable |
03 | tool.Activated:Connect( function () -- When the tool is activated |
04 | if cooldown = = false then -- Detects if the "cooldown" variable is equal to false |
05 | game.Players [ tool.Parent.Name ] .leaderstats.Money.Value = game.Players [ tool.Parent.Name ] .leaderstats.Money.Value + 1 -- Gives the player the cash. replace "Money" with the name of your currency |
06 | cooldown = true -- Sets the "cooldown" variable to true |
07 | script.Disabled = true -- makes it so the tool will no longer give the player money |
08 | wait( 1 ) -- Wait one second. Change to the cooldown time of the tool |
09 | script.Disabled = false -- makes it to the tool will start giving the player money |
10 | end -- Ends the "if" statement. |
11 | end ) -- Ends the function. |
If you still need help, reply to this answer. Thanks!