Need help to fix my car

hi i had made crafting craft game but i have some problems that Wheel are not able to turn and move although the properties AngularVelocity of HingeConstraint still change .Pls help me fix that , Thx !

Video:

This is Assemble Code:

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local SS = game:GetService("ServerStorage")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Char)
	--	Char.Parent = SS
	end)
end)

RS.RemoteEvent.Assemble.OnServerEvent:Connect(function(player,ListOfParts)
	local Contraption = Instance.new("Model")
	local AnchorPart = Instance.new("Part")
	local AnchorPart = Instance.new("Part")
	local ControllFolder = Instance.new("Folder")
	ControllFolder.Parent = Contraption
	ControllFolder.Name = "Motors"
	AnchorPart.Size = Vector3.new(1,1,1)
	AnchorPart.Position = Vector3.new(0,0,0)
	AnchorPart.CanTouch = false
	AnchorPart.CanCollide = false
	AnchorPart.Anchored = false
	AnchorPart.Parent = Contraption
	AnchorPart.Transparency = 1
	Contraption.PrimaryPart = AnchorPart
	Contraption.Parent = workspace
	-- Build
	for _,PartInfor in pairs(ListOfParts) do
		local Part:Model = RS.Buildings:FindFirstChild(PartInfor[1]):Clone()
		local WeldConstraint = Instance.new("WeldConstraint")
		WeldConstraint.Part0 = Part.PrimaryPart ; WeldConstraint.Part1 = AnchorPart ; WeldConstraint.Parent = AnchorPart
		Part:PivotTo(CFrame.new(PartInfor[2].X,PartInfor[2].Y,PartInfor[2].Z))
		Part.Parent = Contraption
		Part.PrimaryPart.Anchored = false
		Part.PrimaryPart.CanCollide = true
	end
	-- Function
	local Seat = nil
	for i,v:Model in pairs(Contraption:GetChildren()) do if not v:HasTag("Seat") then continue end Seat = v break end
	-- Wheel
	for i,v:Model in pairs(Contraption:GetChildren()) do
		local function LeftOrRight(Wheel:Model)
			local Pos = Wheel.PrimaryPart.Position.X - Seat.PrimaryPart.Position.X
			if Pos > 0 then return "L" end
			if Pos < 0 then return "R" end
			if Pos == 0 then return "_" end
		end
		if v:HasTag("Wheel") then
			v.Name = LeftOrRight(v).."F"
			local HingeConstraint = Instance.new("HingeConstraint")
			local WheelAttachment = Instance.new("Attachment")
			local BodyAttachment = Instance.new("Attachment")
			
			BodyAttachment.Parent = Seat.PrimaryPart
			BodyAttachment.WorldCFrame = v.PrimaryPart.CFrame
			WheelAttachment.Parent = v.Wheel
			WheelAttachment.WorldCFrame = v.PrimaryPart.CFrame
			
			HingeConstraint.Attachment0 = WheelAttachment
			HingeConstraint.Attachment1 = BodyAttachment
			HingeConstraint.ActuatorType = Enum.ActuatorType.Motor
			HingeConstraint.MotorMaxTorque = 200000
			HingeConstraint.Parent = ControllFolder
			HingeConstraint.Name = LeftOrRight(v).."M"
		end
	end
	-- Add Controller
	local ControllScript = RS.Script.Controller:Clone()
	ControllScript.Parent = Contraption
end)

Controller Code:

local Contraption = script.Parent
local ControllerFolder = Contraption:FindFirstChild("Motors")
local Seat:VehicleSeat = nil ; local LM:HingeConstraint = {} ; local RM:HingeConstraint = {}
local Speed = 100
local RotateSpeed = 100

for i,v:Model in pairs(Contraption:GetChildren()) do
	if v:HasTag("Seat") then
		Seat = v:FindFirstChildWhichIsA("VehicleSeat")
	end
end
for	i,v in pairs(ControllerFolder:GetChildren()) do
	if v.Name == "LM" then
		table.insert(LM,v)
	elseif v.Name == "RM" then
		table.insert(RM,v)
	end
end

Seat:GetPropertyChangedSignal("Steer"):Connect(function() -- Left/Right
	for i,v in pairs(LM) do
		v.AngularVelocity = Speed * Seat.Throttle
	end
	for i,v in pairs(RM) do
		v.AngularVelocity = Speed * -Seat.Throttle
	end
end)

Seat:GetPropertyChangedSignal("Throttle"):Connect(function() -- Forward/Backward
	for i,v in pairs(LM) do
		v.AngularVelocity = Speed * Seat.Throttle
	end
	for i,v in pairs(RM) do
		v.AngularVelocity = Speed * Seat.Throttle
	end
end)

I know this is unrelated to the post, but you should use handles to place the blocks, not your cursor.

Is any part of the car Anchored?
Are the wheels welded to anything? In test mode go to the Model tab and in the Constraints tools click Show Welds. If there’s a green cube (possibly with a green or gray line) then there’s a WeldConstraint in there somewhere.
Or the weight of the wheels may be too much for the MotorMaxTorque of 200000 to be enough.

I also recommend dropping the MotorMaxAcceleration way down. If it’s too high the wheels would go from 0 AngularVelocity to 100 instantly, which makes them spin and causes control issues. Imagine a 1000 horsepower car with instant acceleration in the real world and you’ll understand what I mean.
I normally use 5-50 for my vehicles, depending on the weight of course.

1 Like

that problem is i made weld constraint on the wheel . Thank you so much !

1 Like

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