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

I am getting "Attempt to index function with 'Value' on this script, why?

Asked by
Axmos 25
4 years ago
Edited 4 years ago

I don't know why this is happening since I've done this before, I have tried replacing ""..i.." with ""..i, but with no luck. Can someone please help me here?

My script:

local function Timer()
    while true do
        Status.Value = "Waiting for 2 players..."

        repeat wait() until game.Players.NumPlayers >= 1

        for i = intermissionLength, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value = "Intermission"
            Timer.Value = ""..i..""
        end
        for i = roundLength, 1, -1 do
            InRound.Value = true
            wait(1)
            Status.Value = "Current round"
            Timer.Value = ""..i.." seconds left!"
        end
    end
end

spawn(Timer)

1 answer

Log in to vote
0
Answered by 4 years ago

I'm assuming Timer on line 11 is a variable. If that's the case, then you are creating two variables with the same name, the newer one being the function Timer, overwriting the old Timer variable. This makes the script think you are trying to index a function with a property. The solution is to rename one of these variables, I suggest renaming Timer to StartTimer.

Ad

Answer this question