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

This if statement is not working when its running?

when I run the script, it didn't work. The output said the "=" was an error

if Humanoid.Health = 50 then
	Head.BrickColor = BrickColor.new("Really red")	
end

1 answer

If statements make comparisons while the "=" sign is used to assign values. Instead you need to use the relational operator "==" which basically just means is equal to. It's also important to understand that the "==" operator compares two parameters and returns a boolean. So the correct code would be...

if Humanoid.Health == 50 then
   Head.BrickColor = BrickColor.new("Really red") 
end

1 comment

0

Essentially, use "==" when reading values, and use "=" when changing them.

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