Your missing a lot of code from the tutorial idk if you followed the whole tutorial but this was the final code:
local car = script.Parent
local seat = car.Body.VehicleSeat
local body = car.Body.Body
local physicsService = game:GetService("PhysicsService")
local DefaultCollisionGroup = "Default"
local CharacterCollisionGroup = "Character"
local cooldown = 0
local OccupiedPlayer
local OccupiedClientScript
local carClientScript = script.CarClient
local function Cooldown(duration)
local cooldownTag = tick()
cooldown = cooldownTag
delay(duration,function()
if (cooldown == cooldownTag) then
cooldown = 0
end
end)
end
local function SetCharacterCollide(character,ShouldCollide)
local group = (ShouldCollide and DefaultCollisionGroup or CharacterCollisionGroup)
for _,part in ipairs(character:GetDescendants()) do
if (part:IsA("BasePart")) then
part.Massless = not ShouldCollide
physicsService:SetPartCollisionGroup(part, group)
end
end
end
local function BodyTouched(part)
if (seat.Occupant or cooldown ~= 0) then return end
local character = part.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if (not player) then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if (not humanoid) then return end
seat:Sit(humanoid)
OccupiedPlayer = player
SetCharacterCollide(character,false)
car.PrimaryPart:CanSetNetworkOwnership(player)
OccupiedClientScript = carClientScript:Clone()
OccupiedClientScript.Car.Value = car
OccupiedClientScript.Parent = player.Backpack
Cooldown(2)
end
local function OccupantChanged()
if (seat.Occupant) then return end
if (OccupiedPlayer.Character) then
SetCharacterCollide(OccupiedPlayer.Character,true)
end
if (OccupiedClientScript.Parent) then
OccupiedClientScript.Stop.Value = true
local client = OccupiedClientScript
delay(3, function()
client:Destroy()
end)
end
car.PrimaryPart:SetNetworkOwnershipAuto()
OccupiedPlayer = nil
OccupiedClientScript = nil
Cooldown(3)
end
body.Touched:Connect(BodyTouched)
seat:GetPropertyChangedSignal("Occupant"):Connect(OccupantChanged)