Character not rotating with Vehicle Seat (Turret Script)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a Basic Turret for future games. I know I’ve made another post in this catergory for Mouse Position, I also want one for the W A S D keys

  2. What is the issue? Include screenshots / videos if possible!
    Whenever the seat is rotating, the character wasn’t rotating with it

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked in the Dev Hub and couldn’t find any

Here is a video of what is happening:

https://gyazo.com/b8c4f6f354647f442078a610375ee544

And here is the Script (LocalScript)

game:GetService("RunService").RenderStepped:Connect(function()
	if workspace.Part.Throttle == 1 then
		
    workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(-0.75,0,0)


	elseif workspace.Part.Throttle == -1 then
		
    workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0.75,0,0)



	end

	if workspace.Part.Steer == 1 then
		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0,-0.75,0)

	elseif workspace.Part.Steer == -1 then

		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0,0.75,0)
	end
end)

When a player sits in a seat, a weld is created to attach the player to the seat. I actually just learned this a few weeks ago, but the parts attached to a part via a weld will only move with the part if you update the CFrame. Updating the position or orientation will only move the seat, not any parts connected to it with a weld (this includes the player’s character). Try changing the seats orientation using CFrame instead of orientation.

See when I use CFrame, and when the Player presses the W and D key the Z value gets changed for some reason

Would you mind sending your CFrame code?

1 Like

Here

game:GetService("RunService").RenderStepped:Connect(function()
	if workspace.Part.Throttle == 1 then
		workspace.Part.CFrame = workspace.Part.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-0.75),0,0)


	elseif part.Throttle == -1 then
		workspace.Part.CFrame = workspace.Part.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(0.75),0,0)



	end

	if workspace.Part.Steer == 1 then
		workspace.Part.CFrame = workspace.Part.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(-0.75),0)



	elseif workspace.Part.Steer == -1 then
		workspace.Part.CFrame = workspace.Part.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(0.75),0)



	end



end)

I can think of two easy solutions off the top of my head:

  • Manually set the players orientation to match the part (one extra line for each orientation set)
  • Try using a weld constraint rather than just a weld (Might or might not work)

I will try the second option as the first one didn’t work.

Would you know what the Part0 and Part1 be?

Put the weld constraint in the chair
part0 is the chair,
part 1 is the HumanoidRootPart of the player

Note: You will need to remove the original weld for this to work

I get this error
image

If you dont show me what you did I cant help fix it,

Though from the error it looks like you set part0 to the model not a part, so set the Part0 to a part inside of the seat model

Note that this is in StarterCharacterScripts

local constrait = Instance.new("WeldConstraint")
constrait.Parent = workspace.Part
constrait.Part0 = workspace.Part --VehicleSeat




game:GetService("RunService").RenderStepped:Connect(function()
	
	if workspace.Part.Throttle == 1 then
		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(-0.75,0,0)
		constrait.Part1 = script.Parent.HumanoidRootPart
		


	elseif part.Throttle == -1 then
		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0.75,0,0)
		constrait.Part1 = script.Parent.HumanoidRootPart
		


	end

	if workspace.Part.Steer == 1 then
		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0,-0.75,0)
		constrait.Part1 = script.Parent.HumanoidRootPart
		

	elseif workspace.Part.Steer == -1 then
		workspace.Part.Orientation = workspace.Part.Orientation + Vector3.new(0,0.75,0)
		constrait.Part1 = script.Parent.HumanoidRootPart


		
		

	end



end)