I am making a camping game and i am working on the cars that teleport you into the game right now and the problem i am having is when i walk up to the part that teleports you onto the truck this comes up

ignore the --


 Workspace.CarTP1.Script:13: attempt to index nil with 'Clone'
 Stack Begin
 Script 'Workspace.CarTP1.Script', Line 13
 Stack End


This is my script:
local Car = game.Workspace.Car1 -- Change "Car1" to the name of your car
local Seats = game.Workspace.Car1.Seats:GetChildren() -- Locates the Group of seats in your car
local Gui = script.Parent:FindFirstChild("ExitGui") -- 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.ExitGui: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)

4 comments

0

Please insert a code block to type this; I don't think anyone will be able to understand this

0

I do not know what this big pile of letters is. Insert Code Blocks PLeASE.

0

format plz

0

It means Gui wasn't found. Use WaitForChild to compensate for asset loading