Changing CFrame to specific position while animation is playing

  1. What do you want to achieve?
  • How move CFrame into part desired while playing animation
  1. What is the issue?
  • It doesnt move into what I intended
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
  • Yes, but nothing seems solving my problem

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


-Intended

But…

-Issue

You may try using TweenService or CFrame:Lerp().
Also, can you provide the script?

local hum = script.Parent:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
anim.Looped = false
anim:Play()

Well, now after you play the animation, wait some time and either Lerp or Tween the character.

image
So uh, i wanted it to be front not to the left. Also do i have to change the orientation?

local hum = script.Parent:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
anim.Looped = false

local LC1 = workspace.LC1
local LC2 = workspace.LC2

local tweenService = game:GetService("TweenService")

anim:Play()
task.wait(1) 
tweenService:Create(script.Parent.PrimaryPart, TweenInfo.new(0.25), {CFrame = CFrame.new(4.091, 4.106, -48.951)}):Play() -- (4.091, 4.106, -48.951) is the location of LC2

You do not have to change the orientation. Looks like the LC2’s front is rotated in that direction. Just turn your part 90 degrees and that should fix it.
You can also right click the part in Explorer and enable Show Orientation Indicator.

I did, even if i resized it and rotated it
image
But let me check the Show Orientation Indicator

image
Should i change to lerp ?

No, you forgot to actually insert LC2 into the script.

tweenService:Create(script.Parent.PrimaryPart, TweenInfo.new(0.25), {CFrame = CFrame.new(4.091, 4.106, -48.951)}):Play()

Should be

tweenService:Create(script.Parent.PrimaryPart, TweenInfo.new(0.25), {CFrame = LC2.CFrame}):Play()

This did not work in the first case because the orientation will be (0, 0, 0).

1 Like

Ah thank you it finally worked but its a temporary fix because i wanted it to go with the animation. Maybe i should moved the torso instead of using the whole CFrame in animating.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.