This script is in a localscript located in the button, the GUI is in "ReplicatedStorage" yet it doesn't clone it.
I have no errors in my output.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() local c = game.ReplicatedStorage.DJPanel:Clone() c.Parent = player.PlayerGui end)
Sorry about the comment above. I looked into it, and I realized I made a mistake. The reason I think it's not working is because you can't access ReplicatedStorage
from a LocalScript
. Change that script into a regular Script
, then follow these steps:
1. Insert an ObjectValue
with the same parent as the Script
. Rename it to Player
2. Insert a new LocalScript
into the ObjectValue
. Put the following code into it:
script.Parent.Value=game.Players.LocalPlayer script:remove()
3. Use this in the regular Script
:
local player = script.Parent.Player.Value script.Parent.MouseButton1Click:connect(function() local c = game.ReplicatedStorage.DJPanel:Clone() c.Parent = player.PlayerGui end)
Anyways, if you follow these steps correctly, it should work. If you have any further problems, please leave a comment below. Hope I helped :P
Make sure this script is a local script as a descendant of StarterGui
or StarterPack
.
repeat wait() until game.Players.LocalPlayer Player = game.Players.LocalPlayer DJPanel = game.ReplicatedStorage:WaitForChild("DJPanel") script.Parent.MouseButton1Click:connect(function () local c = DJPanel:Clone() c.Parent = Player:WaitForChild("PlayerGui") end
For lines 1-3, this was implemented because you might have to wait until the player itself is not nil.
As for line 5, I made a variable to pause the thread until it's not nil, so there will be no errors. Put some print function lines after that, so that if the output isn't saying anything, that means the script can not find the desired object at that time and may indicate that the object doesn't exist.