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

I cant get the tool to add money when i click?

Asked by
mikwbm 9
3 years ago

i have a tool and i am trying to add +1 money every time i click with tool how do i make that happen

local money = game.Players.LocalPlayer.LeaderBoard.Money.Value
local tool = game.StarterPack.Tool


1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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:

local tool = script.Parent -- Defining the tool.
cooldown = false -- Making the cooldown variable
tool.Activated:Connect(function() -- When the tool is activated
  if cooldown == false then -- Detects if the "cooldown" variable is equal to false
  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
  cooldown = true -- Sets the "cooldown" variable to true
  script.Disabled = true -- makes it so the tool will no longer give the player money
  wait(1) -- Wait one second. Change to the cooldown time of the tool
  script.Disabled = false -- makes it to the tool will start giving the player money
end -- Ends the "if" statement.
end) -- Ends the function.

If you still need help, reply to this answer. Thanks!

Ad

Answer this question