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

How can I get the GUI to go away when jumping off the seat?

I made this script for my Airport check in. When the Airport staff sits down, they can control the conveyor via a GUI. But when you jump up it's still there. I can't find the code through the wiki. Any suggestions?

gui = game.Lighting.CheckIn 

function getGUI(u)
print("hit")
h = u.Parent:FindFirstChild("Humanoid")
if h ~= nil then
print("human")
user = game.Players:GetPlayerFromCharacter(u.Parent)
gtest = user.PlayerGui:FindFirstChild("CheckIn") 
if gtest == nil then
local g = gui:Clone()
g.Parent = user.PlayerGui
print("Cloned")
end
end
end

script.Parent.Touched:connect(getGUI)

1 answer

✓ Accepted answer

I think using a TouchEnded event might work:

gui = game.Lighting.CheckIn 

function getGUI(u)
	print("hit")
	h = u.Parent:FindFirstChild("Humanoid")
	if h ~= nil then
		print("human")
		local user = game.Players:GetPlayerFromCharacter(u.Parent)
		local gtest = user.PlayerGui:FindFirstChild("CheckIn")
		if gtest == nil then
			g = gui:Clone()
			g.Parent = user.PlayerGui
			print("Cloned")
		end
	end
end

function removeGUI()
	if g then
		g:Destroy()
	end
end

script.Parent.Touched:connect(getGUI)
script.Parent.TouchEnded:connect(removeGUI)

Here's the wiki link, for reference.

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