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

How do I set this variable to a leaderstat??

Asked by 2 years ago

So I want the variable "Upgrades" to be the value of the leaderstats I have name "Upgrades" How would I do that?

1local Upgrades = 1
2game.ReplicatedStorage.anything.OnServerEvent:Connect(function(player)
3    player.leaderstats.Blocks.Value = player.leaderstats.Blocks.Value + Upgrades
4end)

1 answer

Log in to vote
1
Answered by 2 years ago

You can create an attribute.

01game.ReplicatedStorage.anything.OnServerEvent:Connect(function(player)
02    local leaderstats = player:WaitForChild("leaderstats")
03    local Upgrades = leaderstats:GetAttribute("Upgrades")
04    if not Upgrades then -- if the attribute wasn't created yet
05        leaderstats:SetAttribute("Upgrades", 1) -- creates the attribute
06        Upgrades = 1 -- defines Upgrades as 1 (default)
07    end
08 
09    leaderstats:WaitForChild("Blocks").Value += Upgrades
10end)
0
I put it in and still does the same thing. dannybuns03 11 — 2y
0
Wdym? T3_MasterGamer 2189 — 2y
0
As in you want it to show in the leaderboard? T3_MasterGamer 2189 — 2y
0
So I want it so when you get the remote event signal, the leaderstat: "Blocks" changes by the value of the l leaderstat "Upgrades" dannybuns03 11 — 2y
View all comments (2 more)
0
I don't get it. T3_MasterGamer 2189 — 2y
0
Show me an example. T3_MasterGamer 2189 — 2y
Ad

Answer this question