I am working on making a keyboard hero arena basic copy and I have a script which checks if the player chatted a certain word or not and it not working(the error was "expected 'then' near '=') and this is my script:
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if msg = script.Parent.Name then script.Parent.Zombie.Health = 0 end end) end)
this is in a normal script, is in the enemy that you need to eliminate and the error is on line 3.
Do this
If msg == script.Parent.Name then --Code end
When making an if statement add the ==
when you want to compare
>= greater than equal to
<= less than equal to
~= not equal to
== equal to
In your if
statement, change if msg = script.Parent.Name then
to if msg == script.Parent.Name then
When comparing values in an if statement, use ==
instead of =
== is for comparing
While
= is for declaring variables.
Hope this helps!
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if msg == script.Parent.Name then script.Parent.Zombie.Health = 0 end end) end)
just like coltn said... cos ==
is Comparing something and =
is wen u want to assign something...