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

Gui isnt working?

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

2 answers

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.Workspacewill obviously always return false. Thus, the contents of the block is never executed.

1 comment

0

Our answers sound about the same xD Great answer!

There are a few problems with your script.

  • Local Scripts Can't Access ServerStorage.

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
  • Your checking the parent before defining the parent!

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!

1 comment

0

Oh yeah, forgot to mention the fact that it is a localscript.

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