Tweening a character smoothly

I want to make a smooth effect which tweens the player to the last checkpoint instead of just abruptly teleporting the player back.

Even though it works, it is extremely laggy and choppy, which I believe is due to the delay in the character following its humanoid root part.

I tried searching up the devforum for people who might have experienced something similar but couldn’t really find anything as such. If anyone has any idea of how I can make this smoother using tween or any other method that would work better, please let me know.

Here’s the code that I am currently using:

local TweenService = game:GetService("TweenService")

script.Parent.Touched:Connect(function(hit)
	if Players:GetPlayerFromCharacter(hit.Parent) then
		local Player = Players:GetPlayerFromCharacter(hit.Parent)
		for i,v in pairs(game.Workspace.Checkpoints:GetChildren())do
			if Player.leaderstats.Stage.Value == v.Value.Value then
				local CFrameTween = TweenService:Create(hit.Parent.HumanoidRootPart,
					TweenInfo.new(2.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0),
					{CFrame = v.CFrame + Vector3.new(0,2.5,0)})
				CFrameTween:Play()
			end
		end
	end
end)

Video of the character tween:

robloxapp-20201227-0326200.wmv (880.4 KB)

3 Likes

You could try anchoring the HumanoidRootPart during the process of the tweening as it would be likely that its physics are interrupting through it.

If you wanna take some measures to make the tweening less choppy, try tweening the RootPart on the client. Any changes on the character that is on the client will be able to replicate on the server.

P.S: Please put ``` from the top to the bottom of the code instead of putting it in a quote. It will make it easier to read your code that way.

3 Likes

It worked! It’s alot smoother now! Thank you so much for your help!

However, I do have a question, I thought that tweening anchored parts didn’t work, how come it’s working now?

Tweening anchored parts does work? Tweening a part’s CFrame doesn’t correlate into physics at all. When you anchor a part, it only stops any possible interaction with its physics. It doesn’t entirely restrict its movement.

1 Like

Tweening isn’t moving per say, it’s more teleporting the part really fast between a lot of close points. It doesn’t actually change the velocity which the anchored property locks.

1 Like

Hmm! It is a lot less rough but strangely enough it still shakes slightly? I tried setting the camera subject to the RootPart since I thought maybe that it was the body parts that were shaking, but it is actually the HumanoidRootPart which is shaking, I also turned of CanCollide. Not to sure why it is still shaking, do you have any idea? https://gyazo.com/661793c27547af34305647f5263739ea

did u find a solution for this ?

Anchor the Humanoid root part of the character