How do i make the script continue running when the player is seated?

local CollectionService = game:GetService("CollectionService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.CharacterAdded:Wait() or workspace:FindFirstChild(Player.Name)
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local CarsIngame = workspace.CarsIngame

--Remotes
local Remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")
local OnCollision = Remotes.OnCollision

local PlayerVehicle = nil

--Get the player's vehicle
CarsIngame.ChildAdded:Connect(function(child)
	if child:IsA("Model") then
		if child.Name == Player.Name then
			PlayerVehicle = child
		end
	end
end)

CarsIngame.ChildRemoved:Connect(function(child)
	if child:IsA("Model") then
		if child.Name == Player.Name then
			PlayerVehicle = nil
		end
	end
end)

local CollisionParts = PlayerVehicle:WaitForChild("CollisionParts")

local function OnCollision(hit)
	if CollectionService:HasTag(hit, "Prop") or CollectionService:HasTag(hit.Parent, "Prop") then
		print("dddddddddd")
	end
end

for i, part in pairs(CollisionParts:GetDescendants()) do
	if part:IsA("BasePart") then
		part.Touched:Connect(OnCollision)
	end
end
print("asd")

I have tried googling, using if statements and so on but could not figure it out :confused:
Please help me!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.