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

Is it possible to move and rotate the model at the same time?

Asked by
InLeXiX 18
4 years ago

I'm looking for a way to move and rotate the model using TweenService, but I can't figure anything out

0
CFrame Leamir 3138 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

To rotate and move a model you have some options here, but there are two main ones. You could either Weld everything to the PrimaryPart and use TweenService on the PrimaryPart or you could use SetPrimaryPartCFrame with Lerping and TweenService:GetValue().

OPTION 1:

TweenService:Create(Model.PrimaryPart, TweenInfo.new(1), {CFrame = CFrame.new(0,1, 0) * CFrame.Angles(0, math.pi, 0)}):Play()

OPTION 2:

local Origin, End = Model:GetPrimaryPartCFrame(), CFrame.new(0,1, 0) * CFrame.Angles(0, math.pi, 0)
local Alpha = 0
RunService.RenderStepped:Connect(function(Delta)
    Alpha = Alpha + Delta

    Model:SetPrimaryPartCFrame(Origin:Lerp(End, TweenService:GetValue(Alpha, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)))
end)
0
Nice! Roger111 347 — 4y
Ad
Log in to vote
0
Answered by
Roger111 347 Moderation Voter
4 years ago
Edited 4 years ago

ANSWER: You can add more attributes to be changed in a Tween.

Example:

local TweenService = game:GetService("TweenService")

local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace

local goal = {} -- Here is where you can add all of your attributes
goal.Position = Vector3.new(20, 10, 0) -- Attribute 1
goal.Orientation = Vector3.new(90,0,0) -- Attribute 2

local tweenInfo = TweenInfo.new(7)

local tween = TweenService:Create(part, tweenInfo, goal)

tween:Play()

Note: As well you can just use a new CFrame in the goal object rather than picking a new position and orientation.

Log in to vote
-2
Answered by 4 years ago

First: You can't move and rotate a model, you do it with a part. Second: Don't use TweenService to just move and rotate a part.

So now im gonna explain you how to move and rotate a part: 1) Make a variable for your part for example: local part = workspace.Part 2) Give me more details about how you wanna move it, but right now i will suppose you want to do it when you join but you can change the function. game.Player.PlayerAdded:Connect(function() 3) To move it do: part.Position = Vector3.new(The position you want to move it) 4) To rotate it do: part.CFrame = part.CFrame * CFrame.Angles(?, math.ram(?), ?) ? Means the number you have. If still confused it would be something like this: part.CFrame = part.CFrame * CFrame.Angles(0, math.ram(-45), 0) Orientation property has 3 numbers, the middle number goes inside that parentheses of math.ram(?), and the other numbers to the side.

Why not with TweenService? That isn't made to move and rotate a part...

1
TweenService is to smoothly change any attributes, why woudn't I use it for CFrames(position/orientation)? Leamir 3138 — 4y

Answer this question