I want to be able to click a TextButton and have +1 Point to be added to the players leaderstat Server Side!
✓ ANSWER ACCEPTED
How would i add leaderstats to a player 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
1 comment
0
Should have been a comment.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
indent yo code plz
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
the parameter is the client that fired the OnServerEvent