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

Why does the GUI did not move to PlayerGUI ? ::atempt to call a nil value

Asked by 4 years ago

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:

local p = game.Players.LocalPlayer
local ClickDetector = script.Parent.ClickDetector

function onClick(click)
    local PlayerGui = p.PlayerGui
    local WasteBinGui = game.ReplicatedStorage.GUI.WasteBin.WasteBinGUI
    local Clone = WasteBinGui:Clone()
    Clone.Parent = PlayerGui

end

ClickDetector.MouseClick:connect(onClick)
0
GUI's can only be accessed by localscripts. rabbi99 714 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Thank you guys for your grat help ^^^ pinopeltzi 7 — 4y
Ad

Answer this question