TweenService is moving the HumanoidRootPart to the correct position, but the character gets moved to the wrong position

Okay, this is kind of hard to explain, so I’ll show a video of what’s happening below.

The player gets moved into the sky, however the HumanoidRootPart, which is the only part that is being tweened. You can see this from the camera, I’m not sure where to go from here. I’m using a RemoteEvent for the tween to make it smooth though.

Here’s the normal serverscript:

function move(h)
	
	local humanoid = h.Parent:FindFirstChild("Humanoid")
	
	if humanoid then
		
		local torso = h.Parent.HumanoidRootPart
		
		game:GetService("ReplicatedStorage").TweenPlayer:FireAllClients(h, script)
	end
	
end

script.Parent.Touched:Connect(move)

Here’s the localscript:

function move(h, scriptReceive)
	
	local humanoid = h.Parent:FindFirstChild("Humanoid")
	
	if humanoid then
	
		local torso = h.Parent.HumanoidRootPart
	
		local ts = game:GetService("TweenService")
	
		local tween = ts:Create(torso, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {Position = scriptReceive.Parent.Parent.Destination.Position})
		
		tween:Play()
	end
end

game:GetService("ReplicatedStorage").TweenPlayer.OnClientEvent:Connect(move)
2 Likes

Try and tween the CFrame instead, like so:

local tween = ts:Create(torso, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = CFrame.new(scriptReceive.Parent.Parent.Destination.Position)})
9 Likes

Late response sorry.
It worked but why does it work? I’d like to know as it could keep me from making this mistake in the future.

1 Like

If you try to set the rootpart’s position in a regular manner like e.g. RootPart.Position = Vector3.new() then it’ll break the joints connected to it and cause the character to die. This would not happen if you set the CFrame instead.

I don’t know why the joints didn’t break with tweenservice, but I knew it wouldn’t work in a normal matter so it was a guess really. Though, I’m glad it worked out for ya. :slight_smile:

2 Likes

Ah okay, so CFrame just keeps it kind of proportional if that makes sense?

Thanks for the help!

I’m really not sure, ahah. The only difference between position and CFrame AFAIK, is that CFrames contain both position and rotation data.

1 Like

Yeah, that makes sense. Thanks again!

1 Like

I had similar issue before. Tween position has a lot of issues. Tween CFrame works for most of time.

2 Likes

Glad you found a solution but I would advise not bumping posts, especially considering it’s > 1 year later :stuck_out_tongue:

1 Like