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

01game.Players.PlayerAdded:connect(function(player)
02    if player.Name == "Player" then
03        player.Chatted:connect(function(msg)
04     if msg == "go" then
05        game.Workspace.xTranquil.Taxi.VehicleSeat.MaxSpeed = "200"
06    elif msg == "stop" then
07        game.Workspace.xTranquil.Taxi.VehicleSeat.Maxspeed = "0"
08        end)
09    end
10end)
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 — 10y

1 answer

Log in to vote
1
Answered by
yumtaste 476 Moderation Voter
10 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.

01game.Players.PlayerAdded:connect(function(player)
02        player.Chatted:connect(function(msg)
03if player.Name == "Player" then
04     if msg == "go" then
05        game.Workspace.xTranquil.Taxi.VehicleSeat.MaxSpeed = "200"
06    elseif msg == "stop" then --fixed that spelling mistake
07        game.Workspace.xTranquil.Taxi.VehicleSeat.Maxspeed = "0"
08          end --i added this end
09        end --moved the ) to the end below this one
10    end)
11end)
0
Oh, ok will try and report back, thanks. h19rry 20 — 10y
0
"game.Players.PlayerAdded:connect(function(pla..."]:8: unexpected symbol near ')' is what I get. h19rry 20 — 10y
Ad

Answer this question