Why isn't this working as intended (Player CFrame)?

Hey there,

I’ve made this script run once a Player has died and it should be lifting them up as far as i’m aware? but it doesn’t seem to be working (No errors in output)

Script:

local travel = 20
for i = 0, travel do
hit.Parent:FindFirstChild(“HumanoidRootPart”).CFrame = hit.Parent:FindFirstChild(“HumanoidRootPart”).CFrame +Vector3.new(0,1,0)
wait()

Thanks,

First of all, a better aproach to moving the Player’s character model would be to use the :SetPrimaryPartCFrame method of the Model class. Also, you will need to set the Anchored property of the HumanoidRootPart to true.

local travel = 20
local char = hit.Parent
local humanoidRoot = char:FindFirstChild("HumanoidRootPart") --Only do the search for the root part once
humanoidRoot.Anchored = true
for i = 0, travel do
   char:SetPrimaryPartCFrame(humanoidRootPart.CFrame + Vector3.new(0,1,0))
   wait()
end

Yeah that kinda works, But its not moving them up slowly as i had expected with teh for loop it kinda just teleports them to the Position?

EDIT
Sorry! I forgot to add a wait() line in my code. Check back to my example, but TweenService is still the better route!

Yes. Because that is exactly what the code you have written says to do. Look into the TweenService (roblox.com)

Alright thanks guys, ill take a look into TweenService.

I made this concept a while back for a different problem. The coding is a bit more complex than your situation needs, but ill link it here if you need to take a look at an implementation using the TweenService!
AnimationWithMotor6D_Transform.rbxl (22.9 KB)