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

Help with making a Gui pop up when a part is touched?

I need help making a Gui pop up when a part in workspace is touched. I tried to do it myself but it wasn't working. I restarted the script and I need help with the rest.

local customize = workspace.Custom customize.Touched:connect(function(hit)

end)

1 comment

0

Thanks for your answers

2 answers

✓ Accepted answer

Something like this would work:

local customize = workspace.Custom.customize.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if Player then
			Player.PlayerGui.ScreenGui.Enabled = true
		end
	end
end)
part = game.Workspace.partname
gui = script.Gui

part.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player.PlayerGui.guinamehere then
gui:Clone().Parent = player.PlayerGui
end
end)

This piece of code should work.

Change the variable part to the parts location that you want to activate the touched function.

Change the variable gui to the gui's location

Change guinamehere to the name of the GUI

If you'd like the part to remove the gui if its already open we can do this by adding something simple:

part = game.Workspace.partname
gui = script.Gui

part.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player.PlayerGui.guinamehere then
gui:Clone().Parent = player.PlayerGui
elseif player.PlayerGui.guinamehere then
player.PlayerGui.guinamehere:Destroy()
end
end)

If this doesn't work please let me know any error(s) outputted and I'll help you fix it.

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