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

How to work with chatting and tables?

Asked by
dreamy67 135
11 years ago

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

01admins = {"dreamy67"}
02 
03game.Players.PlayerAdded:connect(function(player)
04 
05    p.Chatted:connect(function(speaker, message, chatColor)
06        if message == "/myname" and player == admins then
07            Instance.new("Message",PlayerGui).Text = player
08        end
09    end)
10end)

1 answer

Log in to vote
0
Answered by 11 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:

01admins  =  {"namehere"}
02 
03game.Players.PlayerAdded:connect(function(p)
04    for i,v in pairs(admins) do
05        if p.Name == v then
06            p.Chatted:connect(function(msg,rec)
07                if msg:lower() == "/myname" then
08                    if p.PlayerGui == true then
09                        local pg = p.PlayerGui
10                        local msg = Instance.new("Message",pg)
11                        msg.Text = (p.Name)
12                        wait(3) --waits to remove
13                        msg:Destroy()
14                    end
15                end
16            end)
17        end
18    end
19end)
Ad

Answer this question