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

The GUI doesn't appear , and there aren't any errors can somebody help ?

Im trying to make a part where there is a ClickDetector inside of it and when you click it a GUI pops up . Im using a local script since i want that when you click a button and only the player who clicked it can see it . The script is inside ReplicatedFirst and the script Parents the GUI . But when i use this script ,nothing pops up

workspace:FindFirstChild("Part").ClickDetector.MouseClick:Connect(function()
	local oGUI = game.ReplicatedStorage.ScreenGui
	     if oGUI then
		local GUI = oGUI:Clone()
		GUI.Parent = player.PlayerGui
	end
end)

Also when i tried using

local player = game:GetService("Players").LocalPlayer
workspace:FindFirstChild("Part").ClickDetector.MouseClick:Connect(function()
	local oGUI = game.ReplicatedStorage.ScreenGui
	     if oGUI then
		local GUI = oGUI:Clone()
		GUI.Parent = player.PlayerGui
	end
end)

It only says 23:59:06.147 - Part is not a valid member of Workspace can anybody help ?

1 answer

I know exactly what is causing the problem. It is mainly because your script runs before the part is loaded in. It can be fixed using workspace:WaitForChild("Part",10) . Re-write your scripts with:

workspace:WaitForChild("Part", 10).ClickDetector.MouseClick:Connect(function()
	local oGUI = game.ReplicatedStorage.ScreenGui
	if oGUI then
		local GUI = oGUI:Clone()
		GUI.Parent = player.PlayerGui
	end
end)

This will start to run as soon as the part gets loaded in. Try Replacing your script with mine and I am sure it will work.

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