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

How would i add leaderstats to a player server side? [closed]

Asked by 6 years ago

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

Closed as Not Constructive by User#24403, ee0w, and yHasteeD

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
tacotown2 119
6 years ago
Edited 6 years ago
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

0
indent yo code plz User#23365 30 — 6y
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 User#23365 30 — 6y
0
the parameter is the client that fired the OnServerEvent User#23365 30 — 6y
Ad
Log in to vote
0
Answered by
Synth_o 136
6 years ago

Remote Events:

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0
Should have been a comment. User#24403 69 — 6y