How do I make a GUI appear on the players screen who is seated in a specific chair and when a ProximityPrompt Gets Triggered by another player

ok, I see you got it working, however, I will go ahead and post my results, just in case anyone is interested.

Passport.rbxl (64.0 KB)

image
image
image
image

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)
2 Likes

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)

Good job, you did a great job recreating everything. You even created a passport counter, bravo.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.