You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I would like to lerp an unanchored object.
-
What is the issue? Include screenshots / videos if possible!
it is not the intended result that I hoped for.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The method i tried is on the code block below, but I haven’t really explored other options other thene tween service because I don’t know what to do.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function module.MoveStand(stand, char, cframe)
local standHRP = stand.HumanoidRootPart;
local charHRP = char.HumanoidRootPart;
local prevWeld = charHRP.standWeld;
prevWeld:Destroy();
local charCF = charHRP.CFrame * cframe
for i = 0, 1, 0.1 do
standHRP.CFrame:lerp(charCF, i);
wait();
print(i)
end
CreateWeld(stand, char);
end
thanks
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
1 Like
Moving around unanchored parts can be tricky business, as the object your moving is also being affected by the physics engine at the same time! I’m not completely sure what you’re attempting to achieve, but I would suggest anchoring the object while it’s being moved, and then un-anchoring it when it reaches its destination.
In your code, probably something like:
function module.MoveStand(stand, char, cframe)
local standHRP = stand.HumanoidRootPart;
local charHRP = char.HumanoidRootPart;
local prevWeld = charHRP.standWeld;
prevWeld:Destroy();
local charCF = charHRP.CFrame * cframe
standHRP.Anchored = true
for i = 0, 1, 0.1 do
standHRP.CFrame:lerp(charCF, i);
wait();
print(i)
end
CreateWeld(stand, char);
standHRP.Anchored = false
end
I just tried it out and the grey thing (which is stand) doesn’t move at all but after the for loop is done the weld is still connected. What I am trying to do is smoothly move the Stand from point(a) to point(b)
this is point B
Oh! If that’s the case, you could try lerping the weld’s C0 (or C1 depending on your setup) property, as opposed to destroying it and making a new one. Something like:
function module.MoveStand(stand, char, cframe)
local charHRP = char.HumanoidRootPart;
local weldOrigin = charHRP.standWeld.C0
for i = 0, 1, 0.1 do
charHRP.standWeld.C0 = weldOrigin:lerp(cframe, i);
wait();
print(i)
end
end
Keep in mind that C0 a CFrame that dictates where Part1 is relative to Part0, so we don’t need to know anything about the character’s CFrame when interpolating it.
1 Like