Trying to make 2 leaderstats

I’m trying to make 2 leaderstats but only 1 shows up, any reasons why?

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local timeingame = Instance.new("IntValue")
	timeingame.Name = "Time"
	timeingame.Parent = leaderstats

	local towers = Instance.new("IntValue")
	towers.Name = "Towers Completed"
	towers.Parent = leaderstats
	while true do
		wait(1)
		player.leaderstats.Time.Value = player.leaderstats.Time.Value + 1
	end
end)

Any help would be greatly appreciated!

1 Like

Something else must be editing the leaderstats since the script you made works fine for me, I also modified it a bit so its shorter. You should also be using task.wait() since wait() is going to get deprecated, more info on the announcement of the task library.

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local timeingame = Instance.new("IntValue")
	timeingame.Name = "Time"
	timeingame.Parent = leaderstats

	local towers = Instance.new("IntValue")
	towers.Name = "Towers Completed"
	towers.Parent = leaderstats
	
	while true do
		task.wait(1)
		timeingame.Value += 1
	end
end)

(Both your original script and my modified version work for me)
I’ll also just throw in a screenshot.
image

Probably that your device isn’t wide enough to fit both names on the leaderstats display.

1 Like

that could be the reason lol, i was using it while it was in a small window

1 Like

try again with a bigger window and see if it works, also please include screenshots if it doesn’t!

image

check the leaderstats folder and see if the value is actually being created

I think I see the issue here
image
2 leaderstats folders are being created

yeah I tried to reply to that aswell!

edit: It already creates a folder for you so it’s a done script.

The only reason I can come up with for this is that there is another script creating the leaderstats folder. Try this:

Press control + shift + f, to search in all scripts. Then type ‘leaderstats’ in the search bar and press enter. This will show all the scripts that use the word ‘leaderstats’ in them. If there are any scripts that do this, you can edit them to fix this issue.

1 Like

Figured it out, it was loading in the local leaderstats rather than the datastore leaderstats
for some reason theres 2 from the way that my friend coded it.
image

that’s great to hear! Hope your game goes well!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.