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

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

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.

2 comments

0

Any errors ?

0

^ this. What type of script is it? Have you tried adding prints to see around the code to see if it actually runs

1 answer


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)

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