Detect when the Animation Track has ended / stopped connect a function then get the Last Position of the HRP. Then position the player to that Last Position
I believe the code may look something like this
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://<your_animation_id>"
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack.Stopped:Connect(function()
local lastPosition= humanoidRootPart.Position
-- Move the character to that position
humanoidRootPart.CFrame = CFrame.new(lastPosition)
end)
animationTrack:Play()
If the animation is always the same, and it, let’s say, puts you 1,000 studs in one direction across the map, just teleport the player 1,000 studs in that direction. @McGamerNick’s reply is probably the solution, but incase not, even if teleporting in that direction isn’t a very dynamic and is pretty sloppy, always works.
yea its just its more what @McGamerNick said i havent tried it out yet but its just if i have a animation that makes me jump backwards in the air and land or something it would cframe me to where the animation landed, im aware for this example you could use velocity stuff instead of moving the torso but im just saying if i want to move the torso and the whole body to a diffrent place in the game with a animation i want to actually be there when the animation ends
you shouldn’t use “hrp.CFrame = (cframe value)” because it’s not a viable way to teleport a player. instead, you should do something like this
char:PivotTo((cframe value))
where char is the parent of the HumanoidRootPart.
in your case, you would want to do something like this:
local plrCFrame = hrp.CFrame
char:PivotTo(hrp.CFrame)
however, there’s another problem where you play the animation in the server, which you shouldn’t do. you should almost always play player animations inside a LocalScript. if you want to teleport the player to the CFrame when the animation ended, you would need to attach a RemoteEvent. like this:
I don’t really think you should do this in the first place. you might want to make the animation have a walking animation itself, but not move within the animation. instead you could make the player automatically move itself through forces
you can, but that’s basically just setting a part position to somewhere client-wise. this will make the changes not visible for the server and other clients. I am unsure if this is still the case for players, but I still wouldn’t recommend because some stuff might be de-synced in a way
may I ask why isnt it a viable way to teleport the player I genuinely dont know why I use it all the time like what downsides does it have
also whats the downsides of playing animations on the server does it increase packets or memory alot? I also do it alot and dont really know the downside I know it wasnt good but I dont know why its bad I would assume packets since I assume smooth moving part on server aka tween or lerp = high packets
Basically using PivotTo() is more secure since its a model and it ensures everything in the model gets moved accordingly-- Versus using PrimaryPart.CFrame.
Aka Roblox Built In Functions over anything most of the time.
again, playing on the server will have the server wait until it gets the message for the animation to be played. it wouldn’t be relative to the client which makes it a tiny bit delayed, which is a big no-no in this case.
for setting the hrp CFrame, it’s a more worse way to go about doing it because :PivotTo() will move every other part along with the PrimaryPart, while setting the position of the rootPart relies on welds.
Im horrible with grab skills currently as I never do them and I see people make the animations and include all the moving of the torsos and the grabber and the grabbed player moving around inside the animation not staying on the same spot so i did it like that then just welded the 2 players humanoidrootparts and the animation did the rest
for example the animation the 2 players characters start the animation inside eachother and in the first keyframe i pose them and get them to have some distance and do the whole animation from there but at the end it would return all the characters parts to the rootpart
so they would just sort of tween back to their orignal position so i didnt want that to happen so thats why I wanted to teleport the characters to their end of animation positions that was my thought process since not alot of grab tutorials exist other then the bad ones
I tried lots of diffrent ways to Cframe the rootpart at the end of the animation but not really anything else i will not being cframing the root part any longer now though I did see a plugin or module earlier for a constant moving rootpart wherever the torso goes in your animations but i think it wouldnt really be worth using but i guess ill try just use velocity
its just i hate messing with velocity it always goes wrong i either overshoot the distance or it makes me slide forward too much or its too slow or too fast
I don’t see why you can’t set the character CFrame. matter of fact I did that in one of my games where I was unable to use forces. however if you want to go down this path and you are having trouble with forces, just create a new post about it