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

:clone() not working, why?

I am trying to make a folder in server storage called "gui" clone into the players "PlayerGui". But its not working...

I made a LocalScript in Workspace with the folloing code inside:

serverStorage = game.GetService("ServerStorage")

game.Players.PlayerAdded:conect(function(player)
	
		local guiloader = serverStorage.gui:Clone()
			
		player:WaitForChild("PlayerGui")		
		guiloader.Parent = player.playergui
end)

3 comments

0

Change "playergui" on line 8 to "PlayerGui"

0

Alright sorry, another problem I didn't notice. Let me update my answer real quick

0

Should be correct now

2 answers

✓ Accepted answer

One problem is simply the fact that you are using a Localscript. Try using a regular Script.


The reason for this is that ServerStorage and ServerScriptStorage are only accessible by regular scripts, and ReplicatedStorage and ReplicatedFirst are only accessible by Localscripts.


The other problems are as follows:

You need to change 'playergui' on line 8 to 'PlayerGui'

Change the period on line 1 to a colon. GetService is a method, and you need to use it properly.

Change "conect" on line 3 to "connect". Simple spelling error.


Your final code should now look like this:

serverStorage = game:GetService("ServerStorage")

game.Players.PlayerAdded:connect(function(player)

	local guiloader = serverStorage.gui:Clone()

	player:WaitForChild("PlayerGui")        
	guiloader.Parent = player.PlayerGui
end)

Anyways, I hope this helped. If not, or if you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped!

3 comments

0

It is still not working.

0

Alright, let me test it and see if I can figure out a way to get it working

0

Thanks, it works now!

local serverstorage = game.ServerStorage
game.Players.PlayerAdded:connect(function(player)
	serverstorage.gui:Clone().Parent = player.PlayerGui
end)

i use

local serverStorage = game.ServerStorage

instead of

serverStorage = game:GetSerive("ServerStorage")

if it helps upvote me pls

3 comments

0

They both do the same thing......

0

serverStorage = game:GetService('ServerStorage') .. just saying :P

0

lol yeh didnt notice that

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