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

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

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!

Ad

Answer this question