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 add leaderstats to a player server side?

I want to be able to click a TextButton and have +1 Point to be added to the players leaderstat Server Side!

2 answers

✓ Accepted answer
first make remote in replicated storage
-- local script
local remote = game.ReplicatedStorage.Remote -- find remote
local plr = game.Players.LocalPlayer -- find player to use in normal script
local gui = script.Parent -- put local script in the gui u wanna click

gui.MouseButton1Click:Connect(function()-- setting clicking function
remote:FireServer() -- firing remote
end)

--serverscript
local remote = game.ReplicatedStorage.Remote -- finding remote

remote.OnServerEvent:Connect(function(plr) -- when remote fired this will start i also passed trough plr so we can use that
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1 -- this is a example of a value but yeh im adding +1
end)

i might have forgotten something so might not work comment if so

3 comments

0

indent yo code plz

0

also you never used the "plr" variable, unless you were thinking about the player parameter of OnServerEvent; which you dont need to define from the caller

0

the parameter is the client that fired the OnServerEvent

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