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

Can't get msg:chatted working?

Asked by
h19rry 20
9 years ago

This is my code, I want it to set the vehicle speed to "200" when I chat go and to "0" when I chat stop, can't understand why this doesn't work.

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "Player" then
        player.Chatted:connect(function(msg)
     if msg == "go" then
        game.Workspace.xTranquil.Taxi.VehicleSeat.MaxSpeed = "200"
    elif msg == "stop" then 
        game.Workspace.xTranquil.Taxi.VehicleSeat.Maxspeed = "0"
        end)
    end
end)
0
Helping out yumtaste here, you're missing a normal "end" after line 7. Feel free to upvote this if it helped. He did answer your question though. IXLKIDDO 110 — 9y

1 answer

Log in to vote
1
Answered by
yumtaste 476 Moderation Voter
9 years ago

Lol on line 6 it says elif. I'm sure you meant elseif. That looks like the only error to me.

EDIT: I can't explain it, so I'm going to fix your code and tell you what I changed.

game.Players.PlayerAdded:connect(function(player)
        player.Chatted:connect(function(msg)
if player.Name == "Player" then
     if msg == "go" then
        game.Workspace.xTranquil.Taxi.VehicleSeat.MaxSpeed = "200"
    elseif msg == "stop" then --fixed that spelling mistake
        game.Workspace.xTranquil.Taxi.VehicleSeat.Maxspeed = "0"
          end --i added this end
        end --moved the ) to the end below this one
    end)
end)

0
Oh, ok will try and report back, thanks. h19rry 20 — 9y
0
"game.Players.PlayerAdded:connect(function(pla..."]:8: unexpected symbol near ')' is what I get. h19rry 20 — 9y
Ad

Answer this question