Why Is This Basic Time Script Not Working?

Hey There! I was wondering why my basic leader stats script isn’t working? Heres the script

local leaderstats = Instance.new("Folder")
local timeInGame = Instance.new("IntValue")

game.Players.PlayerAdded:Connect(function(player)
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	timeInGame.Name = "Minutes"
	timeInGame.Parent = leaderstats
	
	while wait(1) do 
		player.leaderstats.Minutes = player.leaderstats.Minutes.Value + 1
	end
end)

I am very confused as to why this is not working since Minutes is clearly under the leaderstats folder in the Player

You need to create the leaderstats folder first


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

	while wait(1) do 
		player.leaderstats.Minutes = player.leaderstats.Minutes.Value + 1
	end
end)

I forgot to copy and paste it lol leaderstats is here

1 Like

Add .Value and use the variable

game:GetService("Players").PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local timeInGame = Instance.new("IntValue")
	timeInGame.Name = "Minutes"
	timeInGame.Parent = leaderstats
	
	while task.wait(1) do 
		timeInGame.Value += 1
	end
end)
1 Like

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