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