Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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 <eof>' 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

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
4 years ago
Edited 4 years ago
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)


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 Mr_Unlucky 1085 — 4y
0
Another problem was that level was not defined since it was not inside the "onPlayerJoin" function. Mr_Unlucky 1085 — 4y
0
Thanks! I'll try this. AidanTES 36 — 4y
0
Also, yeah when I did wait(30):Connect(timePassed) it did underline it so I will try my fixed script then yours. AidanTES 36 — 4y
View all comments (2 more)
0
Why didn't you accept my answer Mr_Unlucky 1085 — 4y
0
Oops, forgot to! AidanTES 36 — 4y
Ad

Answer this question