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

how would i make a tool add leaderstats?

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

2 answers

✓ Accepted answer

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.

3 comments

0

Good stuff but couldn’t exploiters can edit the script and change the currency increment way higher?

0

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).

0

Does it have to delete the tool after?

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

0

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.