I am trying to spawn maps in when there are two or more players in the game. When the map is chosen, a gui will pop up displaying the map, map name and who made it. This is the Local Script, but the server script for everything else can be found here: https://scriptinghelpers.org/questions/31040/map-spawning-loop-fix
player = game.Players.LocalPlayer guis = player.PlayerGui.ScreenGui for i, v in pairs(game.ServerStorage:GetChildren()) do vclone = v:Clone() if vclone.Parent == game.Workspace then guis.Frame.Madeby.Text = "Made by: Spoookd" guis.Frame.MapName.Text = vclone.Name end end
On line 5 you browse through the children of game.ServerStorage
but on line 7 you test whether the clone's parent is game.Workspace
. A clone is an exact copy of an object, which means the Parent property of the clone will be the same as the original. Since the parent remains the same, vclone.Parent == game.Workspace
will obviously always return false. Thus, the contents of the block is never executed.
There are a few problems with your script.
To fix this, change the script to this, and move everything from ServerStorage
to ReplicatedStorage
.
local player = game.Players.LocalPlayer local guis = player.PlayerGui.ScreenGui for i, v in pairs(game.ReplicatedStorage:GetChildren()) do local vclone = v:Clone() if vclone.Parent == game.Workspace then guis.Frame.Madeby.Text = "Made by: Spoookd" guis.Frame.MapName.Text = vclone.Name end end
In line 5, you define a variable of the cloned object "v". When making a clone, the parent is nil until defined. So I would suggest, not doing this. I'm unsure of what you're trying to do. But I'm simply getting rid of it.
local player = game.Players.LocalPlayer local guis = player.PlayerGui.ScreenGui for i, v in pairs(game.ReplicatedStorage:GetChildren()) do local vclone = v:Clone() guis.Frame.Madeby.Text = "Made by: Spoookd" guis.Frame.MapName.Text = vclone.Name end
For the record, v's parent will always be ReplicatedStorage
because that's where you're getting it.
This might have not have been very helpful, but good luck.
Good Luck!