local Passpart = game.Workspace.PassPart
local prox = Passpart.ProximityPrompt
local Seat = game.Workspace.SMSEAT
local PassportGui = game.ReplicatedStorage:WaitForChild("Pasaport Gui")
local SeatedPlayer = nil
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant then
SeatedPlayer = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
else
if SeatedPlayer then
local oldGui = SeatedPlayer.PlayerGui:FindFirstChild("Pasaport Gui")
if oldGui then oldGui:Destroy() end
end
SeatedPlayer = nil
end
end)
prox.Triggered:Connect(function(plr)
if SeatedPlayer then
if SeatedPlayer.Backpack:FindFirstChild("Pasaport") then
print("Pasaport found!")
local newGui = PassportGui:Clone()
newGui.Parent = SeatedPlayer.PlayerGui
else
print("Pasaport not found")
end
else
print("Nobody in seat")
end
end)
No problem! Also note that the script I made does not check the player’s Backpack for the passport, if you want to add this check, change this paragraph of code:
ProximityPrompt.Triggered:Connect(function(Player)
local Humanoid: Humanoid = Player.Character.Humanoid
if Seat.Occupant and Seat.Occupant ~= Humanoid then
local UI: UIBase = Players:GetPlayerFromCharacter(Seat.Occupant.Parent).PlayerGui["Pasaport Gui"].Passaport
if not UI.Visible then
UI.Visible = true
if Connection and Connection.Connected then
Connection:Disconnect()
end
Connection = Seat:GetPropertyChangedSignal("Occupant"):Once(function()
if UI.Visible then
UI.Visible = false
end
end)
end
end
end)
to this
ProximityPrompt.Triggered:Connect(function(Player)
local Humanoid: Humanoid = Player.Character.Humanoid
if Seat.Occupant and Seat.Occupant ~= Humanoid then
local Occupant: Player = Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
local UI: UIBase = Occupant.PlayerGui["Pasaport Gui"].Passaport
if not UI.Visible and Occupant.Backpack:FindFirstChild("Pasaport") then
UI.Visible = true
if Connection and Connection.Connected then
Connection:Disconnect()
end
Connection = Seat:GetPropertyChangedSignal("Occupant"):Once(function()
if UI.Visible then
UI.Visible = false
end
end)
end
end
end)