I think this is correct but its not working...
function onChatted(msg, recipient, speaker) --Function for msg local source = string.lower(speaker.Name) msg = string.lower(msg) if (msg == "disco") then script.Parent.Color = Color3.new(math.random(), math.random(), math.random()) wait(0.5) end end
As RedCombee and Perci1 said, you have to add a connection line at the end. However, there are more than just those problems, so here is a fixed script.
function onPlayerAdded(player) --You need to also do this function onChatted(msg, recipient) --Speaker is not a valid property of Chatted local source = string.lower(player.Name) --This line is unnecessary unless you are using it later in the code. If you are not, you don't need it. msg = string.lower(msg) if msg == "disco" then --You don't need the parenthesis script.Parent.Color = Color3.new(math.random(0, 255), math.random(0, 255), math.random(0, 255)) --You need to do the math.random values. If this is in a part, use BrickColor.Random() instead. wait(0.5) end end player.Chatted:connect(onChatted) --This is the connect line for the onChatted function end game.Players.PlayerAdded:connect(onPlayerAdded)
I hope this helps!