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

[SOLVED] How can I clone a GUI from Serverstorage into StarterGUI?

I'm trying to create a fast travel map, but the GUI won't copy over. I tried with both local scripts and normal scripts. I tried moving it to ReplicationStorage and trying both Local and normal and it still doesn't work! Help please!

local player = game:GetService("Players").LocalPlayer
local points = game.Workspace.PlacePoints
local ui = game.ReplicatedStorage.INFOUI
local loc = ui.UI.Frame.LOCA
local info = ui.UI.Frame.INFO
local newui = ui:Clone()

function onClicked()
	newui.Parent = player.StarterGUI
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

6 comments

0

Cloning something to the StarterGui won't change any thing on the player's side, try parenting it to the PlayerGui

0

and I think you can't clone something from the serverstorage using local scripts

0

Here, use a normal script and write the following:local points = game.Workspace.PlacePoints local ui = game.ReplicatedStorage.INFOUI local loc = ui.UI.Frame.LOCA local info = ui.UI.Frame.INFO local newui = ui:Clone() function onClicked(Player) newui.Parent = Player.PlayerGui end script.Parent.ClickDetector.MouseClick:Connect(onClicked)

0

That worked! Thank you so much!!!!!

0

Make sure to edit your question's title with "[SOLVED]" so people know it had been solved.

0

Thank you, I'll do that.

1 answer

The StarterGui is a service which will clone their contents into the respective player's PlayerGui once they join. When an object is added mid-game, it will not work immediately. When a player resets though, it will be cloned again. So you must use PlayerGui instead of StarterGui. Also, connect is deprecated. Please use Connect.

local player = game:GetService("Players").LocalPlayer
local points = game.Workspace.PlacePoints
local ui = game.ReplicatedStorage.INFOUI
local loc = ui.UI.Frame.LOCA
local info = ui.UI.Frame.INFO
local newui = ui:Clone()

function onClicked()
    newui.Parent = player.PlayerGui
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked)

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