Why is my leaderstat preview name "Value"

print("Hello All!")

I just found out that sometimes, the value on the leaderstats name is “Value”

In the script I have to set the name on “Money”. And this is causing the game some errors. Sometimes also it duplicates and calls one “Money” and another “Value”.

I also tried to search for a variable called “Value” and rename. But the name is “Money”. It previews as “Value”.

image

This is a part of the script.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait()
	local gam = Instance.new("Folder", plr)
	gam.Name = "game"

	local osTime = Instance.new('ObjectValue', gam)
	osTime.Name = "osTime" -- ignore: antiexploit value!

	local leaderstats = Instance.new('Folder', plr)
	leaderstats.Name = "leaderstats"

	local money = Instance.new("IntValue", leaderstats)
	money.Value = ds:GetAsync(plr.UserId) or startamount
	money.Name = "Money"

	money.Changed:Connect(function()
		ds:SetAsync(plr.UserId, money.Value)
	end)
	
	spawn(function() --  closed here to dont make it longer

Try changing it to this:

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr

local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = ds:GetAsync(plr.UserId) or startamount
money.Parent = leaderstats

Always set the Parent property last when creating an Instance.

Yes! It worked. Thanks!
Didn’t know that you have to set the Parent last.

It’s not that you have to per se, it’s more of a performance thing. You can see the post on why that is here.

1 Like