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

Script not finding GUI?

Asked by 9 years ago

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)
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. dyler3 1510 — 9y
0
Still doesn't let me clone it. UnleashedGamers 257 — 9y

2 answers

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

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

0
It says "Player is not a valid member of TextButton" UnleashedGamers 257 — 9y
0
Actually I fixed it. UnleashedGamers 257 — 9y
0
Actually no, lol... I fixed the error and still nothing comes up. UnleashedGamers 257 — 9y
Ad
Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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.

Answer this question