So I want the variable "Upgrades" to be the value of the leaderstats I have name "Upgrades" How would I do that?
1 | local Upgrades = 1 |
2 | game.ReplicatedStorage.anything.OnServerEvent:Connect( function (player) |
3 | player.leaderstats.Blocks.Value = player.leaderstats.Blocks.Value + Upgrades |
4 | end ) |
You can create an attribute.
01 | game.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 |
10 | end ) |