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

How can I make the gui clone from a surfacegui?

Asked by
yoshi8080 445 Moderation Voter
9 years ago

I can't seem to make the gui clone to the playergui. Once I click on it, nothing happens and it doesn't show up on the PlayerGui

player = script.Parent.Parent.Parent.Parent.Parent.Parent.Players
local hand = game:GetService("ReplicatedStorage")
function MouseClick()
    hand:WaitForChild("Sound")
    player:WaitForChild("PlayerGui")
    hand:Clone()

    end
script.Parent.MouseButton1Click:connect(MouseClick)

1 answer

Log in to vote
0
Answered by
Wizzy011 245 Moderation Voter
9 years ago

Currently, this code just clones ReplicatedStorage, which isn't what you're trying to do.

Firstly,

I don't believe your file path to the player is correct, if you remove one of the Parent and .Player then I think this'd be right (don't quote me on that as I'm doing a bit of guess work from your code).

Line one would now be changed to: player = script.Parent.Parent.Parent.Parent.Parent

You should be cloning the name of the item in ReplicatedStorage (I believe this is the item you've called sound, so I'll stick to that)

So on line 6, you'd want to have hand.Sound:Clone()to start with.

However, once you'd cloned this item, you've not told it where to clone to! So what needs to happen is you need to sent the Parent of this newly cloned Gui.

We can do this by changing Line 6 again; we'd now have hand.Sound:Clone().Parent = player.PlayerGui

The full script

Here's an exact copy of what your code should look like:

player = script.Parent.Parent.Parent.Parent.Parent
local hand = game:GetService("ReplicatedStorage")
function MouseClick()
    hand:WaitForChild("Sound")
    player:WaitForChild("PlayerGui")
    hand.Sound:Clone().Parent = player.PlayerGui
    end
script.Parent.MouseButton1Click:connect(MouseClick)

0
Well I tried this , but it didn't seem to work. :c yoshi8080 445 — 9y
Ad

Answer this question