For my game I have a pacecar and I scripted this to basically have it so that if you say "green" in the part would turn green but after I respawn the pacecar the script doesnt work, any thoughts on how you would make it work after its been respawned? The code is:
i = 1
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if (msg == "yellow") then
wait(1)
i = 1
while i >= 1 do
wait(.1)
script.Parent.BrickColor = BrickColor.New("Black")
wait(.1)
script.Parent.BrickColor = BrickColor.New("Bright yellow")
end
end
if (msg == "green") then
wait(.1)
i = i - 1
script.Parent.BrickColor = BrickColor.New("Lime green")
wait(1)
script.Parent.BrickColor = BrickColor.New("Black")
end
if (msg == "red") then
wait(.1)
script.Parent.BrickColor = BrickColor.New("Crimson")
end
if (msg == "caution off") then
wait(1)
script.Parent.BrickColor = BrickColor.New("Black")
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)

1 comment
Are there any errors?