Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[FE] Trying to make a leaderstat that goes up by 1 every 30 seconds, help?

Hi, I'm using filtering enabled to make a leaderstat that goes up by 1 every 30 seconds and it doesn't seem to work, all it does is break the leaderstat and it doesn't work. Also, I am trying this in-game when it doesn't work. It is in serverscriptservice and is a normal script. Error: '10:43:15.738 - ServerScriptServer.Level:17: ')' expected near ' I've tried so many times to fix this script and it's still not working.

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
 
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Value = 0
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

local function timePassed()
	level.Value = level.Value + 1
end

wait(30):Connect(timePassed()

Any tips or any other helpful things? Thanks -Aidan

1 answer

✓ Accepted answer
local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local level = Instance.new("IntValue")
    level.Name = "Level"
    level.Value = 0

	local function timePassed()
	    level.Value = level.Value + 1
	end
	
	while wait(30) do
		timePassed()
	end
end

game.Players.PlayerAdded:Connect(onPlayerJoin)


6 comments

0

The problem was that you did wait(30):Connect(timePassed() when it should be wait(30):Connect(timePassed). However,I am not sure if that even exists so I did a loop instead

0

Another problem was that level was not defined since it was not inside the "onPlayerJoin" function.

0

Thanks! I'll try this.

0

Also, yeah when I did wait(30):Connect(timePassed) it did underline it so I will try my fixed script then yours.

0

Why didn't you accept my answer

0

Oops, forgot to!

This discussion is preserved as it was. New answers, comments, and votes are closed.