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

Expected 'then' when parsing if statement, got '=' help me?

game.Players.PlayerAdded:Connect(function(plr)


local sd = math.random()

if sd = 0 then
	print("NotHaoBorn")
	
	if sd = 1 then
		print("HaoBorn")
	end
end
	
	
end))`

2 answers

When writing if statements, you're required to have two '=' signs.

So, all you need to do is

game.Players.PlayerAdded:Connect(function()
	local sd = math.random()
	if sd == 0 then
		print("NotHaoBorn")
		if sd == 1 then
			print("sd is 1")
		end
	end
end)

Let me know if you have any questions.

In an if statement, putting "==" will check if sd is 0. if you put "~=", it will check if sd is not 0. If you just put an equals sign, it will not work.

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