I think this is correct but its not working...
01 | function onChatted(msg, recipient, speaker) --Function for msg |
02 |
03 | local source = string.lower(speaker.Name) |
04 | msg = string.lower(msg) |
05 |
06 | if (msg = = "disco" ) then |
07 |
08 | script.Parent.Color = Color 3. new(math.random(), math.random(), math.random()) |
09 | wait( 0.5 ) |
10 | end |
11 |
12 | 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.
01 | function onPlayerAdded(player) --You need to also do this |
02 | function onChatted(msg, recipient) --Speaker is not a valid property of Chatted |
03 | 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. |
04 | msg = string.lower(msg) |
05 | if msg = = "disco" then --You don't need the parenthesis |
06 | script.Parent.Color = Color 3. 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. |
07 | wait( 0.5 ) |
08 | end |
09 | end |
10 | player.Chatted:connect(onChatted) --This is the connect line for the onChatted function |
11 | end |
12 | game.Players.PlayerAdded:connect(onPlayerAdded) |
I hope this helps!