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

"for limit must be a number"?

Asked by
Hasburo 150
8 years ago

16:58:52.419 - Workspace.MapChanger:169: 'for' limit must be a number

here's line 169;

for i = 0, time do

& here's the full script;

local event = Instance.new("RemoteEvent")
event.Parent = game.ReplicatedStorage
event.Name = "Timer"
event.OnServerEvent:connect(function()
    for i,v in ipairs(game.Players:GetChildren()) do
        local timeremaining = v.PlayerGui.MapChangerGUI.Selector.TimerConfirm.Amount.Text
        local button = v.PlayerGui.MapChangerGUI.Selector.Timer
        local lol = game.Workspace.Boards.TrainingInfo.SurfaceGui.MainFrame.Display.Host.Time
        local time = tonumber(timeremaining)
        for i = 0, time do
    local minutes = math.floor(time/60)
local seconds = math.floor(time%60)
local seconds2 = math.floor(time)
                        wait(1) 
                        time = time - 1 
    lol.Text = "Timer: "..tostring((minutes..":"..(seconds > 9 and seconds or "0"..seconds2)))
    script.Parent.Parent.Time.Text = "Timer: "..tostring((minutes..":"..(seconds > 9 and seconds or "0"..seconds2)))
    end
    lol.Text = ""
    end
    end)

purpose of the script is to create a timer when fired (it's an event). it is called upon in another script though.

i'm pretty confused. help would be greatly appreciated!

0
i would make the time a numbervalue, but that's just my dumb way of doing things theCJarmy7 1293 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

local timeremaining = v.PlayerGui.MapChangerGUI.Selector.TimerConfirm.Amount.Text

Convert the string value to a number so instead of local time = timeremaining

Make it local time = tonumber(timeremaining)

0
Okay, I edited the main script but it's still not working. Still says the same problem with the 'for' limit must be a number. Hasburo 150 — 8y
0
I do not know what the string for text is but I am assuming it is only consisting of numbers in seconds. Flarebitz 0 — 8y
0
I have no idea what you just said. Hasburo 150 — 8y
Ad
Log in to vote
0
Answered by 4 years ago

I know I am late, but I just wanted to give an answer for this in case anyone is having this same issue. I was having this error, and here is how I fixed it.

Basically what the error says is that the limit (this is the number in the middle aka the 'end value') is not a valid number. This usually happens when you are working with the children of an object or part or whatever, the computer doesn't know what you want it to count the how many parts there are (this is just an example).

Most errors like this can be solved with a simple # in front of the end value.

parts = game.Workspace.Parts:GetChildren()

for i = 1, #parts, 1 do -- insert the # in this line before the end value
    -- insert code here
end

This is how I solved it for me.

Answer this question