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

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

Asked by 9 years ago

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

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
9 years ago

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.

Ad

Answer this question