im making a hovercraft and i have the turning and everything to work but tbh it kind of looks dumb when it turns so i wanted to make it kind of rotate when it turns but when the script changed the rotation (via orentation) then my seat weld breaks :l. is there another way i could rotate my hovercraft? i tried bodygyro but that dident help. i will leave my script i guess



--- varibles ---
seat = script.Parent.Seat
main = script.Parent.Main
issitting = false
force = script.Parent.Main.BodyPosition
speed = 0.01
isgoing = false
isbackwording = false
islefting = false
isright = false 
--- varibles ---

-------functions-----------

seat.ChildAdded:Connect(function()
	issitting = true
	print("issiting = true")

	
end)


seat.ChildRemoved:Connect(function()
	
	issitting = false
	print("issiting = false")
	
end)

function go() -- go function
	
	while isgoing == true and issitting == true do
		
		force.Position = main.CFrame.p + (main.CFrame.lookVector * 6)
		wait(speed)
	end
end
function backwords() -- backword function
	while isbackwording == true and issitting == true do
		force.Position = main.CFrame.p + (main.CFrame.lookVector * -6)
		wait(speed)
	end
end

function right(bool) -- right function
	if bool == true then
		main.BodyAngularVelocity.AngularVelocity = Vector3.new(0,-3,0)
		main.BodyGyro.MaxTorque = Vector3.new(400000,400000,40000)
		main.Orientation = Vector3.new(0,0,-45)
	else
		main.BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)
		main.BodyGyro.MaxTorque = Vector3.new(400000,0,400000)
		main.Orientation = Vector3.new(0,0,0)
		
	end
	
	
end

function left(bool) -- left function
	 if bool == true then
		main.BodyAngularVelocity.AngularVelocity = Vector3.new(0,3,0)
	else
		main.BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)
		
	end
end


---functions -------

---services-----
game:GetService("UserInputService").InputBegan:Connect(function(input, gameproccess)
	
	if input.KeyCode == Enum.KeyCode.W and issitting then
		isgoing = true
		go()
		
		
	end
	
	if input.KeyCode == Enum.KeyCode.S and issitting then
		isbackwording = true
		backwords()
		
		
	end
	
	if input.KeyCode  == Enum.KeyCode.D and issitting then
		isright = true
		right(isright)
		
	end
	if input.KeyCode == Enum.KeyCode.A and issitting then
		islefting = true
		left(islefting)
		
	end
	
end)

game:GetService("UserInputService").InputEnded:Connect(function(input,gameproccess)
	
	if input.KeyCode == Enum.KeyCode.W and issitting then
		isgoing = false
	end
	if input.KeyCode == Enum.KeyCode.S and issitting then
		isbackwording = false
	end
	
	if input.KeyCode == Enum.KeyCode.D and issitting then
		isright = false
		right(isright)
	end
	
	if input.KeyCode == Enum.KeyCode.A and issitting then
		islefting = false
		left(islefting)
	end
end)

---services-------

sorry its like really messy

2 comments

0

Instead of setting it's position, set it's CFrame. Setting the position is what causes it to break. CFrame doesn't.

0

Crazyman32 can show you, he showed me.