Something is wrong with Car teleporation

Hi. So I was making this script when player touches invisible wall it will teleport him to car seat but something is wrong. Here is screenshot of mine script all help will be appreciated.


And here is the code:

local Car = game.Workspace.Car1 -- Change "Car1" to the name of your car
local Seats = Car.Seats:GetChildren() -- Locates the Group of seats in your car
local Gui = script.Parent:FindFirstChild("ExitButton") -- Locates the Exit Button in the Teleport Part
local Gui2 = script.Parent:FindFirstChild("LoadingScreen") -- Locates the Exit Button in the Teleport Part

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			for i,v in pairs(Seats) do
				if Seats.Occupant == nil then
				hit.Parent.Humanoid.JumpPower = 0
				hit.Parent.Humanoid.WalkSpeed = 0
				Gui:Clone().Parent = player.PlayerGui
				player.Character.HumanoidRootPart.CFrame = Seats[math.random(1,17)].CFrame -- Teleports the player to a vacant seat
				wait(10)
				player.PlayerGui.ExitButton:Destroy() -- Change ExitGui to the name of your Exit Button Gui
				for i = 1,100 do -- Moves the car forward
					Car:TranslateBy(Vector3.new(0,0,-1))
					wait() -- Do not change this line
				end
                Gui2:Clone().Parent = player.PlayerGui
                player.Character.Humanoid.JumpPower = 50
                wait(0.2)
                player.Character.Humanoid.Jump = true
                wait(0.2)
                player.Character.Humanoid.JumpPower = 0
                wait(0.2)
				wait()
				player.Character.HumanoidRootPart.CFrame = game.Workspace.GameTeleporter.CFrame -- Teleports the player to the Game Teleport brick
				wait(1)
				player.Character.Humanoid.JumpPower = 50
                wait(0.2)
                player.Character.Humanoid.Jump = true
                wait(0.2)
                player.Character.Humanoid.JumpPower = 0
				wait(15)
				for i = 1,100 do -- Moves Car Reverse
					Car:TranslateBy(Vector3.new(0,0,1)) -- You might have to move the 1 in the position of a 0
					wait() -- Do not change this line
				end
			end
		end
	end
end)

Please send your code in text based format by copying and pasting using the codeblock feature on the forum instead of a screen shot

Images do not help as we cannot edit your code.

9 Likes

thank you Alvin there I added script sorry about that I joined dev forum yesterday so I’m still kinda new and learning to use it.

and how do I use code block ? I couldn’t find it anywhere when editing post.

image

Wrap your code inside those two lines (it’s an image so I can show you)
Using this: `

Please also ensure it is properly indented so we can read it.

7 Likes

there thank you Alvin for your help code is pasted.