Basically what I want to do is move a part on a custom character from one place to another. The solution to this I think is to lerp it to the Humanoid Root Part position but provide another value as a Vector3 to offset it off of the humanoid root part’s position.
Is this in a local script?
How is the variable playerPhysbox set up? If it’s referencing the Player then it won’t work because the Player isn’t in the Workspace at the moment, but their Character is.
It would really help to have the entire script or the sections that deal with the part’s movement.
Alright, it’s part of a larger script with a lot more in but I’ll give everything that is relevant, I might have missed some stuff out so sorry if I have
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local playerPhysboxVector = Vector3.new(0, 1.8, 0)
local playerPhysbox = character.PlayerPhysbox
playerPhysbox.Position = humanoidRootPart.Position + playerPhysboxVector
local function onCrouch(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
playerPhysbox.CFrame = playerPhysbox.CFrame:Lerp(humanoidRootPart.CFrame + Vector3.new(5, 5, 5), 0.2)
elseif inputState == Enum.UserInputState.End then
playerPhysbox.CFrame = playerPhysbox.CFrame:Lerp(humanoidRootPart.CFrame + playerPhysboxVector, 0.2)
end
end
It is in a local script by the way. playerPhysbox is a part of a custom StarterCharacter. It is welded to the HumanoidRootPart using a Weld (not a WeldConstraint - this may help i’m not sure???)
@Pyritium as for using TweenService instead, my understanding is that TweenService only deals with resizing parts instead of moving their position? This part is already resized using a Tween (I’ve cut it out in the code above). I just want it’s position on the body to be different, but for it to move there smoothly and efficiently
@IVoidstarI I tried this, it seems to move the entire character as a whole (i just want this part to move on the character while the player can still move around freely - this is why I assumed Vector3 would work for me)
Thanks for your responses, hope this clarifies some stuff!
i just want this part to move on the character while the player can still move around freely
You probably shouldn’t weld the box to the character then and just directly set CFrame instead to the HumanoidRootPart and just use CFrame.lookAt to have it look towards that direction. When you weld a part to the character, since they’re both technically connected, they will both move at the same time.