I am trying to make a tool that when clicked, will add one cash to the players Cash value on the leaderboard, the code will not execute properly and the cash value remains as 0.
local tool = script.Parent
function CashGiverTool(player)
local PlayerCash = player.leaderstats.Cash
PlayerCash.Value = PlayerCash.Value + 1
end
tool.Activated:Connect(CashGiverTool)
the player variable needs to be defined differently. Activated does not pass the player variable.
local tool = script.Parent
function CashGiverTool()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local PlayerCash = player.leaderstats.Cash
PlayerCash.Value = PlayerCash.Value + 1
end
tool.Activated:Connect(CashGiverTool)