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

Issue with for i < 10 do loop?

i = 0

script.Parent.Touched(function()
	while i < 50 do
	m = Instance.new("Hint", workspace)
	m.Text = i
	wait(1)
	i = i + 1
end)

It error reads there is an unexpected symbol near ")" on line 9, but if I remove ) it breaks.

2 answers

i = 0

script.Parent.Touched:connect(function()--Your forgot to "connect" the function
    while i < 50 do
    m = Instance.new("Hint", workspace)
    m.Text = i
    wait(1)
    i = i + 1
end -- You need a second "end" for the while do loop
end)

A "while" loop is its own code block. Therefore, end is needed after line 8.

i = 0

script.Parent.Touched:connect(function()
	while i < 50 do	-- You could also do a "for" loop instead. It won't take up as much lines.
		local m = Instance.new("Hint", workspace)	-- You're going to end up making 50 messages.
		m.Text = i
		wait(1)
		i = i + 1
	end
end)
-- If you're curious about any of my comments, go ahead and tell me; I will happily explain it to you.

1 comment

0

Thank you. Forgot destory XD

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