Ad
Log in to vote
2

How to work with chatting and tables?

Asked by
dreamy67 135
7 years ago

Im trying to test somethings with chatting and tabels but im trying to make this work, can someone help?

admins = {"dreamy67"}

game.Players.PlayerAdded:connect(function(player)

    p.Chatted:connect(function(speaker, message, chatColor)
        if message == "/myname" and player == admins then
            Instance.new("Message",PlayerGui).Text = player
        end
    end)
end)

1 answer

Log in to vote
0
Answered by 7 years ago

Basically, there are a few things you messed up on, such as searching for an admin. And also the chatted event could be altered/shortened. Try this:

admins  =  {"namehere"}

game.Players.PlayerAdded:connect(function(p)
    for i,v in pairs(admins) do 
        if p.Name == v then 
            p.Chatted:connect(function(msg,rec)
                if msg:lower() == "/myname" then 
                    if p.PlayerGui == true then
                        local pg = p.PlayerGui
                        local msg = Instance.new("Message",pg)
                        msg.Text = (p.Name)
                        wait(3) --waits to remove
                        msg:Destroy()
                    end
                end
            end)
        end
    end
end)
Ad

Answer this question