Hello all! This may be a simple thing but i couldk not find any information.
I have a leaderstats with a IntValue. The value are showing, but not the name of the stat.
My code is this (on a script):
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Ld = Instance.new("IntValue", leaderstats)
Ld.Name = "Gold"
Ld.Value = 10
As you can see in the image, the value is shown but not the name “gold”. I’ve tried with a StringValue but no success. Im trying to make a leaderstats with a StringValue and a IntValue.
[EDIT: the code is working fine. Actually i’ve just discovered that this happens only when you’re the first on the server, or using Play on studio. When you collapse the leaderstats, it starts to show the name]
It’s a server script yes. Thank you for the link, i usually instance things and parent them later but for this scenario i’ve tried instancing inside the parent just in case that was causing the problem, but no luck
Can you provide a .rbxl so that I can reproduce the issue? It seems like there might be another script interfering here, or you’re doing something wrong that I can’t tell from the code provided.
EDIT: Try making ‘leaderstats’ an IntValue, like so:
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Ld = Instance.new("IntValue")
Ld.Name = "Gold"
Ld.Value = 10
Ld.Parent = leaderstats
The issue is that the leaderboard is registering the value before the property is set. You should always make it a habit to set properties before parenting. Not only is it good for performance, but it avoids odd cases such as this.
That aside, it should show just “Value” if the name isn’t set. Values with the name of Value are probably ignored for display. I haven’t had a look at the CoreScripts in some time.
This is not correct, I’ve just tested and you can name them ‘Value’ (or leave them unnamed).
Using the code provided in the OP, I was able to achieve the desired result. If you could provide a .rbxl to reproduce this @cKolmos that would be great.
Actually i’ve just found something strange: when you are the first in the server, the names are not shown until you collapse the leaderstats list. Maybe a windows10 thing?
I fixed it by doing what @LordHammy referenced in his post. By setting the parent after setting the other variables I got it to display normally. It may still be a bug though.
After testing it a few times, it doesn’t actually seem to have worked. It only works when you click on it to hide/show it. Although I only tested it in studio, not outside of it.
It happens to me all the time in Studio. I simply readjust the game window size and the titles reappear. I haven’t seen it happen in the actual game though, so assuming it’s just a Studio thing.