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

Script not finding GUI?

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)

2 comments

0

I've run into the same problem before. Take the gui out of replicated storage. As far as I'm concerned, you can't access it in online mode. I would put it into ServerStorage and try it that way.

0

Still doesn't let me clone it.

2 answers

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

3 comments

0

It says "Player is not a valid member of TextButton"

0

Actually I fixed it.

0

Actually no, lol... I fixed the error and still nothing comes up.

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.

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