I want to make a car that has a hitbox which I will eventually use to damage players with. The problem is, is that whenever I use this hitbox, my car can’t move.
Car Code
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local car = script.Parent
local ID = car.ID
local backLeft = car.BackLeft
local backRight = car.BackRight
local frontRight = car.FrontRight
local frontLeft = car.FrontLeft
local seat = car.VehicleSeat
local steerAngle = 30
local maxSpeed = seat.MaxSpeed / (frontLeft.Wheel.Size.Y/2)
seat.Touched:Connect(function(hit)
if ServerStorage.ServerStatus.Value ~= "Round" or ServerStorage.ServerStatus.Value ~= "Countdown" then return end
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player.UserId == ID then
seat:Sit(player.Character.Humanoid)
else
seat:Sit(nil)
end
end
end)
seat:GetPropertyChangedSignal("SteerFloat"):Connect(function()
frontLeft.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.SteerFloat
frontRight.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.SteerFloat
end)
seat:GetPropertyChangedSignal("ThrottleFloat"):Connect(function()
frontLeft.Wheel.MotorConstraint.AngularVelocity = maxSpeed * seat.ThrottleFloat
frontRight.Wheel.MotorConstraint.AngularVelocity = maxSpeed * -seat.ThrottleFloat
backLeft.Wheel.MotorConstraint.AngularVelocity = maxSpeed * seat.ThrottleFloat
backRight.Wheel.MotorConstraint.AngularVelocity = maxSpeed * -seat.ThrottleFloat
end)
What the car shouldn’t look like:
(My car can’t move and it is sort of stretched out when the rigid constraints inside of it should automatically be forcing it towards the body of the car.)
Also if I destroy this hitbox it completely immobilizes every part because my weldconstraints are inside the hitbox from automatically using the Roblox Constraints Editor.