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

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

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)

1 comment

0

GUI's can only be accessed by localscripts.

1 answer

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.

1 comment

0

Thank you guys for your grat help ^^^

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