--[[ Main Script ]]
--

Players = game:GetService("Players")
Workspace = game:GetService("Workspace")

Seat = script.Parent
GUI = script.GUI
Active = false
Player = nil
NewGui = nil

Seat.ChildAdded:connect(function(Child)
	if Active == false then
		if Child.Name == "SeatWeld" then
			Active = true
			Player = Players:GetPlayerFromCharacter(Child.Part1.Parent)
			if Player ~= nil then
				PlayerGui = Player:FindFirstChild("PlayerGui")
				if PlayerGui ~= nil then
					NewGui = GUI:Clone()
					NewGui.Parent = PlayerGui
				end
			end
		end
	end
end)

Seat.ChildRemoved:connect(function(child)
	if child.Name == "SeatWeld" then
		if Active == true then
			Active = false
			pcall(function() NewGui:Destroy() end)
			Player = nil
			NewGui = nil
		end
	end
end)
