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

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

Asked by 10 years ago

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!

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. GoldenPhysics 474 — 10y

2 answers

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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
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 Coolviper630 95 — 10y
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. adark 5487 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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

Answer this question