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.
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.
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.