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

"for limit must be a number"?

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!

1 comment

0

i would make the time a numbervalue, but that's just my dumb way of doing things

2 answers

✓ Accepted answer

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)

3 comments

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.

0

I do not know what the string for text is but I am assuming it is only consisting of numbers in seconds.

0

I have no idea what you just said.

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.

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