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

How do I add a leaderstats value when you activate a tool?

Asked by 3 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
local tool = script.Parent
game.Players.PlayerAdded:Connect(function(plr)
    tool.Activated:Connect(function()
        local leaderstats = plr:WaitForChild("leaderstats")
        local cash = leaderstats:WaitForChild("Cash")
        cash.Value = cash.Value + 10
    end)
end)

I've been working on this for hours, please help me.

0
Any errors ? Omq_ItzJasmin 666 — 3y
0
^ this. What type of script is it? Have you tried adding prints to see around the code to see if it actually runs Rare_tendo 3000 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

local Tool,Players,player=script.Parent,game:GetService"Players",nil Tool.Equipped:Connect(function() player=Players:GetPlayerFromCharacter(Tool.Parent) end) Tool.Activated:Connect(function() player.leaderstats.Cash.Value+=10 end)
Ad

Answer this question