Clone doesn't exist?

Hello. I’m trying to clone my GUI to the player but for some reason it doesn’t clone it? It’s run on a local script.

	local RadioUI = game:GetService("ReplicatedStorage"):WaitForChild("Radio"):Clone()
	RadioUI.Parent = Player.PlayerGui

The error is this: [attempt to index nil with ‘Parent’]

1 Like

Somehow RadioUi is nil, are you sure it’s named “Radio”?

image

local RadioUI = game.ReplicatedStorage:WaitForChild("Radio"):Clone()
RadioUI.Parent = Player.PlayerGui

I don’t know if I helped or not. I tried :innocent:

Oh my bad, it works if the Clone isn’t there but when the clone is there it doesn’t work. I forgot to put that in my code.

1 Like

What’s the script class-name?

jjtffjjtyjtd

It’s a local script in StarterCharacterScripts.

Is Archivable on on the RadioGui? If not, turn it on, then Clone() should work.

Put it in playerscripts. It’s better for you. Nobody really wants multiple radios :sweat_smile:

Unfortunately…
image

The error below probably means the RadioUI is nil or the Player is nil, did you remember making Player a variable?

Is the new luau thing on for you? I heard there might be some bugs with that, try turning it off and see what happens.

Edit: OH I think I know what’s going on. Clone it on a seperate line and it should work!

Player is a variable and I have tested it and when RadioUI is cloned, it’s nil but when it’s not cloned, it’s perfectly fine.

1 Like

RadioUI must be getting destroyed when it’s created. Have anything that blocks instances
being added into PlayerGui?

I got it to work with the same exact code (except I added a player variable) and no errors, RadioUI.rbxl (20.1 KB) there’s the place if you want to check it out.

2 Likes

If I just clone it, it doesn’t show up in the replicatedStorage.
image

local Lighting = game.Lighting
local Player = game.Players.LocalPlayer

Lighting.Ambient = Color3.fromRGB(10, 10, 10)
Lighting.SCP008Effect.Enabled = false
Lighting.SCP0492Effect.Enabled = false
Lighting.SCP059Effect.Enabled = false
Lighting.NightVision.Enabled = false
if game.Players.LocalPlayer.PlayerGui:FindFirstChild("Ambient") then
	game.Players.LocalPlayer.PlayerGui:FindFirstChild("Ambient"):Destroy()
end

print("Spawn actions completed.")

wait(3)

if Player.Team ~= game.Teams["Class-D"] and Player.Team ~= game.Teams["Class-E"] and not Player.PlayerGui:FindFirstChild("Radio") and Player.PlayerGui:FindFirstChild("Menu").Music.Volume == 0 then

	local RadioUI = game:GetService("ReplicatedStorage"):WaitForChild("Radio")
	RadioUI:Clone()
--	RadioUI.Parent = Player.PlayerGui
--	RadioUI.Frame:TweenPosition(UDim2.new(1, -230, 1, -115),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
	if Player.Team == game.Teams["Chaos Insurgency"] then
		RadioUI.Frame.Raid.Visible = true
	else
		RadioUI.Frame.Main.Visible = true
	end
	
end


if not Player.PlayerGui:FindFirstChild("GunUI") then

local GunUI = game.ReplicatedStorage.GunUI:Clone()
GunUI.Parent = Player.PlayerGui

end

script:Destroy()

This is the whole script if that changes anything.

What I meant was define a variable for the original GUI, then define another variable as a clone of it, then parent it to the player’s PlayerGui.

I tried that before and it didn’t work sadly. Same error. For some reason it’s not letting the client clone it?

Remove the script:Destroy() line and see what occurs.