Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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

0
Lowercase the if ;) OniiCh_n 410 — 10y
Ad
Log in to vote
1
Answered by
OniiCh_n 410 Moderation Voter
10 years ago

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!

Log in to vote
-1
Answered by
KAAK82 16
10 years ago

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

Answer this question