Basically, I made a GUI for my police car, and when I sit for the first time, but the gui shows up when I sit the 2nd time.

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
						end
					elseif active ~= true and seat ~= script.Parent then
						if player.PlayerGui:FindFirstChild("PoliceGUI") ~= nil then
							player.PlayerGui:FindFirstChild("PoliceGUI"):Destroy()
						end
					end
				end
			end)
		end
	end
end)

2 comments

0

"Seat:GetPropertyChangedSignal("Occupant"):Connect" usually more reliable

0

Can you put it in a script in the answers section?