How do I make this work?

I have recently made an attempt to make a script that will increase the leaderstats level for “Value” by one every minute. However, I’m still quite inexperienced in Lua. That’s why I came here; I’m trying to get the leaderstats to increase by one every minute.

The script so far:

game.Players.PlayerAdded:Connect(function(players)

     local leaderstats = Instance.new("Folder",players)

     leaderstats.Name = 'leaderstats'

     local Level = Insance.new(IntValue", leaderstats)

     Level.Name = "Level"
end)
2 Likes

try making it like this:

game.Players.PlayerAdded:Connect(function(players)

	local leaderstats = Instance.new("Folder",players)

	leaderstats.Name = 'leaderstats'

	local Level = Instance.new("IntValue", leaderstats)

	Level.Name = "Level"
	Level.Value = 1
	
	while wait(60) do
		Level.Value = Level.Value + 1
	end
end)
1 Like
game.Players.PlayerAdded:Connect(function(player)

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

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

while wait(60) do
Level.Value += 1
end
end)

Careful with using the Parent argument in Instance.new…
Explanation: PSA: Don't use Instance.new() with parent argument

I fixed up the rest and adding a while do loop which can add the value.

1 Like

Instance not Insance
that’s funny

oh and you shouldn’t use the parent parameter in the Instance.new(), causes memory leaks

1 Like

oh, i copied the first code and made some changes lol

1 Like

Thank you for the response. Now that I have applied the changes that you recommended the leaderstats is no longer appearing.

I made a few changes and found that this works:

game.Players.PlayerAdded:Connect(function(player)

     local leaderstats = Instance.new("Folder")
     leaderstats.Name = "LeaderStats"

     local Level = Instance.new("IntValue")
     Level.Name = "Level"

while wait(60) do
Level.Value += 1
end
end)

Note: There are no errors in the output.

The edit you made is not putting leaderstats under the player. But, if it works for you then I guess it is okay…

The script I provided did work, it probably didn’t appear on the actual leaderboard because of the capitalization for the name of Leaderstats. Roblox is cap-sensitive.

I copied the capitolization exactly as you wrote it… I don’t understand why it’s not working.

Like I said, roblox is cap sensitive so the name has to be leaderstats instead of Leaderstats. (lowercase “L”)

game.Players.PlayerAdded:Connect(function(player)

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

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

while wait(60) do
Level.Value += 1
end
end)

please don’t use the parent argument in instance.new

use this script^^

After some testing I found out that I had a typo in the script. Thanks for the response! :smiley: