--			script.Cam:Clone().Parent = char

			local obj = player:findFirstChild("Turret")
			if obj then
				obj:remove()
			end
			
			
			
			local tur = Instance.new("ObjectValue")
			tur.Name = "Turret"
			tur.Value = seat.Parent
			tur.Parent = player
			script.Parent.Tank:clone().Parent = player.Backpack;
			script.Parent:WaitForChild"TankGUI":clone().Parent = player.PlayerGui;
		end
	end
end

function ChildRemoved(child)
	char = child.Part1.Parent
	player = game.Players:getPlayerFromCharacter(char)
	if player then
		local gui = player.PlayerGui:findFirstChild("TankGUI")
		if gui then
			gui:remove()
		end
		
		local tool = player.Backpack:findFirstChild("Tank")
		if tool then
			tool:remove()
		end
		
		local obj = player:findFirstChild("Turret")
		if obj then
			obj:remove()
		end	
	end
end

seat.ChildAdded:connect(ChildAdded)
seat.ChildRemoved:connect(ChildRemoved)


local character = nil

local self = script.Parent






 

local debounce = false

function Touched (hit)

    if debounce == false then

        if character == nil then -- Prevents more than one player being affected by this function

            if hit.Parent:findFirstChild("Humanoid") then

                character  = hit.Parent

                wait(0.1) -- Wait for the character to sit

                if character ~= nil then

                    if character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then

                        for _, child in pairs(character:GetChildren()) do

                            if child:IsA("Accoutrement") then

                                child = child.Handle

                            end
						
                            if child:IsA("BasePart") then -- BasePart is a class that all "Parts" fall under
							if child.Name == "Head" then
							child.face.Transparency = 1
							end
                                if child.Name ~= "HumanoidRootPart" then -- This is a brick not meant for view

                                    child.Transparency = 1

                                end

                            end

                        end

 

                        local function HumanoidJumped()

                            if character ~= nil then
							
                                if character.Humanoid.Jump == true then

                                    for _, child in pairs(character:GetChildren()) do

                                        if child:IsA("Accoutrement") then

                                            child = child.Handle

                                        end

							if child.Name == "Head" then
							child.face.Transparency = 0
							end

										
										
                                        if child:IsA("BasePart") then
								if child.Name == "Head" then
								child.face.Transparency = 1
								end
                                            if child.Name ~= "HumanoidRootPart" then

                                                child.Transparency = 0

                                            end

                                        end

                                    end

                                    if debounce == false then

                                        debounce = true

                                        character.HumanoidRootPart.CFrame = self.CFrame * CFrame.new(0, 1 + self.Size.Y / 2, -3)

                                        character = nil

                                        wait(1)

                                        debounce = false

                                    end

                                end

                            end

                        end

 

                        character.Humanoid.Changed:connect(HumanoidJumped)

                    end

                end

            end

        end

    end

end

 

self.Touched:connect(Touched)
