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

Can someone help me with this please?[Please, need another answer]

I am trying to make this "MapChooserGui" from Lighting clone into every player's PlayerGui, what I did was:

local mapChooserGui = game.Lighting:FindFirstChild("MapChooserGui"):Clone()

for i,v in pairs(game.Players:GetPlayers()) do
mapChooserGui.Parent = v.PlayerGui
end

This only works once somehow then when the game script repeats gives me this error in the output

The Parent property of MapChooserGui is locked, current parent: NULL, new parent PlayerGui

Someone help me please!

1 comment

0

You are only cloning the GUI once, you need to clone it once per player, not once per server. Also, I recommend putting it in ServerStorage, so the players can't access it.

2 answers

✓ Accepted answer

As GoldenPhysics said, you have to make multiple clones: one for each Player.

local mapChooserGui = game.Lighting:FindFirstChild("MapChooserGui")

for _, v in pairs(game.Players:GetPlayers()) do --We never use 'i', so I marked it as such.
	mapChooserGui:Clone().Parent = v.PlayerGui --I moved the 'Clone' call to here, so it makes a new clone for each Player.
end

2 comments

0

OMG! Thank you so much adark, you were very helpful then the others, also can I know the diffreence between for _, v in pairs(game.Players:GetPlayers()) do and for i,v in pairs(game.Players:GetPlayers()) do? Thx

0

There is no difference, really. I used '' instead of 'i' for the first return variable, because we don't care about it, but we do care about the second. Common practice in Lua is to use '' to "catch" return values you don't intend to use, when the ones you do are returned afterwards, as in this case.

I would have it in a frame, in the players backpack, then have a local script that is on a loop, and the waittime before it activates the frme to appear again is the length per round. such as this:

while true do
wait(enter round time here plus 1 or something)
mapchooser = script.Parent.mapchoosergui.MapChooserGuiFrame
mapchooser.Visible = true
wait(time you want it to appear)
mapchooser.Visible = false
end

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