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

How to change leaderstats value?

I am trying to make a little leaderstats instance and what I'm doing is making it so that when you click an on screen button it will give you 25 points. So how would I go about changing the value from a local script in a button? (I have FilteringEnabled btw)

1 comment

0

Can we see your code please.

1 answer

✓ Accepted answer

Hello, ItsJamsRBLX!

Inside of the TextButton there should be a LocalScript. Inside of this script should be a FireServer event when they click the button. I will only be helping you with the script that controls when the remote is fired.

local Rep = game:GetService("ReplicatedStorage")
local Remote = Rep:WaitForChild("RemoteName")

Remote.OnServerEvent:Connect(function(player) -- this is called when the remote is fired; the argument inside of this is a way you can get the player. the first argument will always be the player
	local PlayerStats = player:WaitForChild("leaderstats") 
	local PlayerCoins = PlayerStats.Coins
end)

Of course, you would have to modify this to your liking.

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