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

I asked for help and someone used a semi-colon, but what do they do?

So, I asked for help on a script on the Roblox developer forum and someone on my script had used semi-colons, but when I changed it and removed them the script didn't work anymore. I wasn't exactly sure what the difference was in what he changed or why the semi-colons fixed the problems. It would be great if someone could explain to me what they mean in my piece of code, due to me being new to coding.

Code:

local plr;
	for i,v in pairs(players:GetPlayers()) do
		if not plr and textEntered == v.Name then
			plr = v;
		end
	end -- There is more code after, but it was irrelevant to enter it

1 comment

0

why not compare with what happened when the person changed the script and the script before you posted?

1 answer

✓ Accepted answer

You should control which semicolons you are removing because there might be code that is relevant to your problem.

For the semicolon supposed to be another way to declare a new statement, similar to line breaking. ie

(This situation is kinda messy)

this causes ambiguous syntax.

local function Print_2(a)
	print(a)
	return function(b)
		print('wow another Function call')	
	end
end
Print_2('wow! a Function call')--> 'wow! a Function call'
(function() --> will this print 'wow another Function call' or not?
	return 'wow new statement'
end)()

This does not

local function Print_2(a)
	print(a)
	return function(b)
		print('wow another Function call')	
	end
end
Print_2('wow! a Function call');--> 'wow! a Function call'
(function() 
	return 'wow new statement' --> this does nothing because it returns a string only.
end)()

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