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 1 year ago

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

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

1 answer

Log in to vote
1
Answered by 1 year ago

You can create an attribute.

game.ReplicatedStorage.anything.OnServerEvent:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
    local Upgrades = leaderstats:GetAttribute("Upgrades")
    if not Upgrades then -- if the attribute wasn't created yet
        leaderstats:SetAttribute("Upgrades", 1) -- creates the attribute
        Upgrades = 1 -- defines Upgrades as 1 (default)
    end

    leaderstats:WaitForChild("Blocks").Value += Upgrades
end)
0
I put it in and still does the same thing. dannybuns03 11 — 1y
0
Wdym? T3_MasterGamer 2189 — 1y
0
As in you want it to show in the leaderboard? T3_MasterGamer 2189 — 1y
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 — 1y
View all comments (2 more)
0
I don't get it. T3_MasterGamer 2189 — 1y
0
Show me an example. T3_MasterGamer 2189 — 1y
Ad

Answer this question