Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Convert a Script to a LocalScript?

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?

1 comment

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)

2 answers

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

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)

2 comments

0

Jill, "_" is a place holder, not an index nor value, so use "i" instead.

0

_ is a place holder.

This discussion is preserved as it was. New answers, comments, and votes are closed.