Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

:clone() not working, why?

Asked by
NRCme 0
8 years ago

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)
0
Change "playergui" on line 8 to "PlayerGui" dyler3 1510 — 8y
0
Alright sorry, another problem I didn't notice. Let me update my answer real quick dyler3 1510 — 8y
0
Should be correct now dyler3 1510 — 8y

2 answers

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
8 years ago

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!

0
It is still not working. NRCme 0 — 8y
0
Alright, let me test it and see if I can figure out a way to get it working dyler3 1510 — 8y
0
Thanks, it works now! NRCme 0 — 8y
Ad
Log in to vote
0
Answered by
Benqazx 108
8 years ago
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

0
They both do the same thing...... NRCme 0 — 8y
0
serverStorage = game:GetService('ServerStorage') .. just saying :P DevNetx 250 — 8y
0
lol yeh didnt notice that Benqazx 108 — 8y

Answer this question