Hey There, i've spent hours researching the web and trying things but still cant learn about functions i need my tool to add a point to my stats when it is used any help is appreciated thanks
how would i make a tool add leaderstats?
2 answers
Well, You at least took the effort to do some research.. You're going to have to make use of Variables, Math, Events, Functions, and Connections.
Usually people use local scripts for tools but if we want to make an actual change to a value in leaderstats then I recommend the use of a server script.
We're going to make a tool that add 1 to a leaderstats value then the tool disappears.
-- Server Script --
-- Variables
local tool = script.Parent -- defining tool
-- Events/Connections
tool.Activated:Connect(function() -- tool "Activated" Event
local character = tool.Parent -- defining character
local players = game:GetService("Players") -- defining players
local player = players:GetPlayerFromCharacter(character) -- defining player
local leaderstats = player.leaderstats -- defining leaderstats
local currency = leaderstats.Money -- defining currency
local addition = 1 -- defining addition
currency.Value = currency.Value + addition -- Adding 1 to Currency
end)
Of course.. This script may error in certain circumstances.. But that's for the better. So you can observe, problem-solve, and understand the errors.
Thanks, but did you say it deletes the tool after? Cuz like I need it to stay and then we use the points to buy other tools that give points, Thanks
1 comment
yeah i did say that.. but i guess i forgot to add that part to my script lol
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Good stuff but couldn’t exploiters can edit the script and change the currency increment way higher?
No. It's a Server Script. Exploiters can't read/edit Server Script. And Exploiter's can't read/edit scripts anymore(at least for now).
Does it have to delete the tool after?