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)