I am trying to stop the truck from moving whenever it collides with a part or humanoid. The problem is that the truck goes through the brick wall but stops when it collides with the humanoid.
This is my code so far:
local truck = script.Parent
local drive = true
truck.mainPart.Touched:Connect(function(hit)
if hit:IsA("BasePart") or hit:IsA("Model") or hit.Parent:FindFirstChild("Humanoid") then
drive = false
print("Touched")
end
end)
while drive do
truck:SetPrimaryPartCFrame(truck:GetPrimaryPartCFrame() * CFrame.new(0,0,0-.1))
wait()
end
What should I do to fix this?