Hello I try to move my "WatseBinGui" from Repiclatedstorage to the PlayerGUI but nothing happens on click.
-- 17:46:55.248 - Workspace.WasteBin.Script:5: attempt to index nil with 'PlayerGui' --
Heres my script:
01 | local p = game.Players.LocalPlayer |
02 | local ClickDetector = script.Parent.ClickDetector |
03 |
04 | function onClick(click) |
05 | local PlayerGui = p.PlayerGui |
06 | local WasteBinGui = game.ReplicatedStorage.GUI.WasteBin.WasteBinGUI |
07 | local Clone = WasteBinGui:Clone() |
08 | Clone.Parent = PlayerGui |
09 |
10 | end |
11 |
12 | ClickDetector.MouseClick:connect(onClick) |
I'm not sure, but i don't think that ReplicatedStorage can render GUIs. I'd instead let a Disabled GUI in PlayerGUI and make enabled clones of it when the function is called.
The script of yours should be successfully indexing the PlayerGUI, but probrably isn't because it's a ServerScript. Transcript the code onto a LocalScript and it should work.