Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I set this variable to a leaderstat??

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

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)

6 comments

0

I put it in and still does the same thing.

0

Wdym?

0

As in you want it to show in the leaderboard?

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"

0

I don't get it.

0

Show me an example.

This discussion is preserved as it was. New answers, comments, and votes are closed.