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

i'm having a problom with this script running any help?

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.

3 answers

✓ Accepted answer

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

1 comment

0

Lowercase the if ;)

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...

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