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

How to change leaderstats value?

Asked by
8jxms 9
4 years ago

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)

0
Can we see your code please. xXTouchOfFrostXx 125 — 4y

1 answer

Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
4 years ago

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.

Ad

Answer this question