I've been trying to make this work. Why doesn't it?
char = game.Players.LocalPlayer.Character r_arm = char["Right Arm"] head = char["Head"] r_arm.Anchored = false while wait() do r_arm.CFrame = r_arm.CFrame:lerp(head.Position,0.90) end
Help would be appreciated.
Here's a fixed version of your script:
local char = game.Players.LocalPlayer.Character local r_arm = char["Right Arm"] local head = char["Head"] r_arm.Anchored = false while wait() do local r_armCFrame = r_arm.CFrame:lerp(head.CFrame,0.90) r_arm.CFrame = r_armCFrame end
Here's what I changed:
First, I added the local
keyword to all of your variables. local
variables have many benefits and should always be used when possible.
You had this line of code:
r_arm.CFrame = r_arm.CFrame:lerp(head.Position,0.90)
Which was changed to
local r_armCFrame = r_arm.CFrame:lerp(head.CFrame,0.90) r_arm.CFrame = r_armCFrame
The reason the old one wasn't working is because lerp
is a function of CFrame
. Just using lerp
doesn't move an object, it returns a CFrame lerped between two CFrames.
That's why you also need to set the CFrame of the object you want to move to what you calculate with lerp
.
I hope this helps. Good luck!