Smooth stand summon

hello everyone,
i’m fairly new to working with roblox studio and lua.
Now I am working on a jojo game as a passion project, to learn a couple of new things
at an ok level.
i want to get my [stand] (Stand | JoJo's Bizarre Wiki | Fandom have a smooth summon.

i did accomplish a rather strange summon by using the code that’s in this picture:
Summon - Roblox Studio 18-6-2020 22_07_10 (2)
even though i’m new to scripting, i know that this is just more something like teleporting the stand to his end position (as shown below).
robloxapp-20200618-2203514.wmv (442.9 KB)

I have tried by adding in an animation to get it right, but this is such a pain since I either need to find the right spot for the animation to end, or find the right position to put the CFrame on. both are very time consuming and aren’t fast to work with considering every stand has another position to be in. i would love if someone could tell me if their is a better way to do this.

thank you for reading my problem.

2 Likes

Lerp the CFrame instead. All CFrames have a built in :Lerp() function, which’ll let you create that smooth transition effect. The parameters for it are (a, b, t), where a is the start position (so HumanoidRP.CFrame) and b is the end position (HumanoidRP.CFrame * CFrame.new(2, 0, 2)), and t is the time. If t is 0, the position is a, and if t is 1, the position is at b.

You could use a simple for loop with a wait(). Something like:

for i = 0, 1, 0.01 do -- adjust the 0.01 to make it slower/faster
    Mystand.HumanoidRootPart.CFrame = CFrame:Lerp(HumanoidRP.CFrame, HumanoidRP.CFrame * CFrame.new(2, 0, 2), i)
end

ok so, i did what you suggested, and i don’t know what i’m doing wrong with it now
but i keep getting following error
Summon - Roblox Studio 18-6-2020 23_47_11 (2)

if needed, this are the lines of code
Summon - Roblox Studio 18-6-2020 23_47_11 (3)

1 Like

Use this code instead, a Lerp usually takes 3 parameters, but the CFrame:Lerp() only takes a goal and an alpha, because it already has the first value. Wasn’t checking the code over, this should work for you

 Mystand.HumanoidRootPart.CFrame = Mystand.HumanoidRootPart:CFrame:Lerp(HumanoidRP.CFrame * CFrame.new(2, 0, 2), i)
1 Like

this does indeed work,
i thank you for helping me out with this.

1 Like