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

Convert a Script to a LocalScript?

Asked by 9 years ago

I'm trying to make a Player List GUI and I made this, but it works in a Script and not a LocalScript.

game.Players.ChildAdded:connect(function(pl)
    table.insert(plrs,pl.Name)
    for i,v in next, plrs do
        if (plrs[i]) == pl.Name then 
            local m = Instance.new("Message",workspace)
            m.Text = "Player is #"..i.." and his name is "..v
        end
    end
end)

Now, the point of that script is to get a players index value and place his picture on to a ImageLabel, but that's not what I need help with right now. I need help with getting it into a LocalScript. Any ideas?

0
First, use game.Players.PlayerAdded:connect(function(plr), also use for _,v in pairs(Plrs) do if v == pl.Name then. Also, m.Text = ('Player is #'..v.userId..' and his name is '..v.Name) MessorAdmin 598 — 9y

2 answers

Log in to vote
2
Answered by
yumtaste 476 Moderation Voter
9 years ago

Why do you need it in a LocalScript? It will only work in a normal script.

Ad
Log in to vote
0
Answered by 9 years ago
local Plrs = {}

game.Players.PlayerAdded:connect(function(Player)
    table.insert(Plrs, {NM = Player.Name,ID = Player.userId} )
    for _,v in pairs(Plrs) do
        if v.NM == Player.Name then
            local m = Instance.new('Hint',workspace)
            m.Text = ("Player is #"..v.ID.." and his/her name is "..v.NM.."!")
        end
    end
end)
0
Jill, "_" is a place holder, not an index nor value, so use "i" instead. Vlatkovski 320 — 9y
0
_ is a place holder. MessorAdmin 598 — 9y

Answer this question