Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I rotate a part to a certain degree and angle at a certain speed?

Asked by 4 years ago

I'm making a turret and it's going to turn when it activates and go on a certain orientation (0, 90, 10). When I activate the script, it just switches to the position I'd like, not at a speed or smooth rotation, just clips. I know I'm doing something wrong here and I haven't added something. Any ideas?

game.Workspace.Frame.Rotation = Vector3.new(0, 90, 10) --The second value of vector3 is a,
wait(5) 
Frame = Frame+3
0
The method below causing the tween to occur is the tween:Play(), im assuming however you're setting your turret, this is running more than once? SerpentineKing 3885 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You can use TweenService to make smooth transitions of movement. I'm not sure what the last two lines are for so I'll just give an example of creating a tween that would make the transition from the current position to your desired rotation.

local TweenService = game:GetService("TweenService")
local TI = TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)

local goal = {}
goal.Rotation = Vector3.new(0, 90, 10)

local turret = workspace:WaitForChild("Frame")
local tween = TweenService:Create(turret, TI, goal)
tween:Play()
0
The thing is kind of wonky, first it clips to a place and then turns to where it should go, overruns it, and then goes to the desired place. How can I fix this? Used_Develop 14 — 4y
0
Bruh, its not duplication, you just will not respond to my question. Used_Develop 14 — 4y
Ad

Answer this question