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

What is wrong with my disco script?

Asked by
Ulysies 50
10 years ago

I think this is correct but its not working...

01function onChatted(msg, recipient, speaker) --Function for msg
02 
03local source = string.lower(speaker.Name)
04msg = string.lower(msg)
05 
06if (msg == "disco") then   
07 
08    script.Parent.Color = Color3.new(math.random(), math.random(), math.random())
09wait(0.5)
10end
11 
12end
3
You don't have a connection line for your function. RedCombee 585 — 10y
1
As it is, this function will never run. Please look up the Chatted event on the wiki. Perci1 4988 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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.

01function 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 = 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.
07            wait(0.5)
08        end
09    end
10    player.Chatted:connect(onChatted) --This is the connect line for the onChatted function
11end
12game.Players.PlayerAdded:connect(onPlayerAdded)

I hope this helps!

Ad

Answer this question