The script is inside the VehicleSeat, but I have to sit twice in order for the GUI to show up.
local ui = script.Parent:FindFirstChild("PoliceGUI") script.Parent.Touched:connect(function(hit) if hit.Parent ~= nil then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent:FindFirstChild("Humanoid") ~= nil then hit.Parent.Humanoid.Seated:connect(function(active, seat) if player ~= nil then if active == true and seat == script.Parent then if player.PlayerGui:FindFirstChild("PoliceGUI")== nil then ui:Clone().Parent = player.PlayerGui print("seated") end elseif active ~= true and seat ~= script.Parent then if player.PlayerGui:FindFirstChild("PoliceGUI") ~= nil then player.PlayerGui:FindFirstChild("PoliceGUI"):Destroy() print("not seated") end end end end) end end end)
Remake of script:
--[[ Services ]]-- local Players = game:GetService("Players") --[[ Instances ]]-- local Seat = script.Parent local UI = Seat:FindFirstChild("PoliceGUI") --[[ Variables ]]-- local Player --[[ Events ]]-- Seat:GetPropertyChangedSignal("Occupant"):Connect(function() if Player then if Player.PlayerGui:FindFirstChild("PoliceGUI") then Player.PlayerGui.PoliceGUI.Visible = false end end if Players:GetPlayerFromCharacter(Seat.Occupant) then Player = Players:GetPlayerFromCharacter(Seat.Occupant) if not Player.PlayerGui:FindFirstChild("PoliceGUI") then UI:Clone().Parent = Player.PlayerGui end Player.PlayerGui.PoliceGUI.Visible = true end end)
Explanation coming later,
Is it possible the PoliceGui is already inside the PlayerGui but invisible? Do a double check and make sure PoliceGui isn't already in StarterGui.