Gui won't clone after reset

The local script is inside StarterPlayerScripts, same as the Gui (its inside the local script). So, when I reset my character, the Gui won’t clone.

The ResetOnSpawn property is enabled.

3 Likes

The gui will need to be in startergui for resetonspawn to be automatic. If you can’t put it in starter gui, then you’ll have to write your own code for cloning it over.

3 Likes

I have a script for cloning it.

1 Like

Is the clone script looking for the gui by a different name than the clone()?

2 Likes

are you even setting its parent?

2 Likes

You can add a listener for player.CharacterAdded so when a character is added (happens on reset) it will clone.

1 Like

LocalScript in StarterPlayerScripts. (Gui must be a descendant of this LocalScript!!)

local Gui = script:FindFirstDescendant("GuiName" --The name of the gui here!)
local Player = game.Players.LocalPlayer

Player.Changed:Connect(function(NewProperty)
    if NewProperty == "Character" and Player then --If the property is the character (respawned), and the player still exists:
        pcall(function()
            Gui:Clone().Parent = Player.PlayerGui or Player:WaitForChild("PlayerGui")
        end)
    end
end)

Untested, but it should work. :smile:

2 Likes

This is the script for cloning it over. This is the script in StarterPlayerScripts,

for _, tv in pairs(game.workspace:WaitForChild("TVs"):GetChildren()) do
	local tvGui = script.TV:Clone()
	tvGui.Parent = queueGui
	tvGui.Adornee = tv.GUI
	tvGui.Enabled = true
	
	for _, room in pairs(tv:GetChildren()) do
		if not room:IsA("ObjectValue") then continue end
		
		local tvRoom = script.TVTemplate:Clone()
		tvRoom.Parent = tvGui.TV.Rooms
		tvRoom.header.Text = room.Value.Name.."'s Room"
		tvRoom.Name = room.Value.Name
		tvRoom.LayoutOrder = tonumber(room.Value.Name)
		
		for _, pc in pairs(room.Value:GetChildren()) do
			local pcGui = script.PC:Clone()
			pcGui.Parent = queueGui
			pcGui.Adornee = pc.GUI
			pcGui.Enabled = true
			pcGui.PC.Heading.Text = "Med+ - "..room.Value.Name.."'s Room" 
			pcGui.tvRoom.Value = tvRoom
			
			for _, btn in pairs(pcGui:GetDescendants()) do
				if btn:IsA("TextButton") or btn:IsA("ImageButton") then
					if buttonCalls[btn.Name] then
						btn.Activated:connect(function()
							buttonCalls[btn.Name](pc)
						end)
					end
				end
			end
		end
	end
end

for _, kiosk in pairs(game.workspace:WaitForChild("Kiosks"):GetChildren()) do
	kioskGui = script.Kiosk:Clone()
	kioskGui.Parent = queueGui
	kioskGui.Adornee = kiosk.GUI
	kioskGui.QueueDispenser.Activated:connect(function()
		buttonCalls["QueueDispenser"](kiosk)
	end)
end

image

I would love to help you, however, at this time Roblox is currently ‘indisposed’.

1 Like