How to rotate with part

Hi,
I am asking how to rotate with part, so it will rotate around its Y and it can free rotate around other axis and the rotation will be smooth, and i can instantly change it.

3 Likes

I don’t see any context of this, what is the use case of the rotation?

1 Like

I just need to rotate the part, and i dont know how to do it.

1 Like

There are many ways:

  • CFrame.Angles
  • BasePart.Orientation

Method:

  • Multiply the part’s original orientation with the new one.
1 Like

Kindly add more specific details. What do you mean by “rotate part”? Are you doing this in studio? Are you creating a script to rotate a part? What have you tried so far to accomplish this?

1 Like

I need to rotate part around its Y using script and i need to instantly change the speed, direction,… of the rotation.

1 Like

I think you’re referring to TweenService. This service allows you to smoothly increment numerical values by specifying several goals and appearance settings. Here’s an example of rotating a part with tween service:

local TweenService = game:GetService("TweenService")
local TweenSettings = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)

local Part = PathToPart
local Tween = TweenService:Create(Part, TweenSettings, {Orientation = Vector3.new(90, 0, 0)})

Tween:Play()

There are a lot of posts that explain how to use tween service, so you may want to explore those. Please search before posting a topic next time.

2 Likes

ok, but i need to change speed and that is problem

1 Like

Change 0.5 in tween settings to the speed of the rotation.

1 Like

ok, but how can i diynamicly change it and same with goal

1 Like

Depending on how you plan to obtain the values for the tween settings, you could always set it up like this:

local Speed = 1
local RotationX = 45
local RotationY = 0
local RotationZ = 0
local Part = PathToPart

local TweenSettings = TweenInfo.new(Speed, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Tween = TweenService:Create(Part, TweenSettings, {Orientation = Vector.new(RotationX, RotationY, RotationZ)})

Tween:Play()
1 Like

I have rotation speed, and i need to change it based on players reactions

local turnSpeed = math.min((Config.SteerSpeed.Value*(math.max(speed-Config.MinTurnSpeed.Value,0)/10)),Config.MaxTurnSpeed.Value)*-script.Parent.Steer
2 Likes

If you need to obtain players’ inputs, you have to make use of UserInputService.

local UserInputService = game:GetService("UserInputService")

local function OnInputBegan(Input, GameProcessedEvent)
    if Input.KeyCode == Enum.KeyCode.D then
        --tween rotation to right
    elseif Input.KeyCode == Enum.KeyCode.A then
        --tween rotation to left
    end
end

local function OnInputEnded(Input, GameProcessedEvent)
    if Input.KeyCode == Enum.KeyCode.D or  Input.KeyCode == Enum.KeyCode.A then
        --tween rotation to center
    end
end

UserInputService.OnInputBegan:Connect(OnInputBegan)
UserInputService.OnInputEnded:Connect(OnInputEnded)

This seems off from the OP’s original question. If you have further questions about using user input service or creating a vehicle using the mentioned services, I’d suggest creating a new post.

1 Like

ok, but how to convert the steer speed to tween

2 Likes

What exactly is steer speed? Is this the speed of the wheels turning left or right?

1 Like

yes, look up, there is the code that compute it

2 Likes
local turnSpeed = math.min((Config.SteerSpeed.Value*(math.max(speed-Config.MinTurnSpeed.Value,0)/10)),Config.MaxTurnSpeed.Value)*-script.Parent.Steer
local TweenSettings = TweenInfo.new(turnSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
1 Like

no, turn speed is its velocity (i used it in code as)

local turnSpeed2 = script.Parent.CFrame:VectorToWorldSpace(Vector3.new(0,turnSpeed,0))
1 Like

Just rotate it around its Y…

2 Likes