I’ve just came across a youtube video where you can use bezier curves and I wanted to give it a try, so I opened studio and it worked amazingly. I wanted to try this on my current project and it’s a bit different since the game has models and not parts. I didn’t think it would be an issue since I can just use the primary part, but I put in the code and nothing happens. I’m basically just trying to lerp the model from 1 position to the other. I have a part that spawn 50 studs out on the Z axis so it can curve to the player, but nothing seems to happen, I thought it may be from the PrimaryPart, but I have no idea.
Here is the code I used:
UpdateClient.OnClientEvent:Connect(function(ingredientInstance)
local hasTool = checkForTool(plr)
if hasTool then
local bopSound = Instance.new("Sound")
bopSound.SoundId = "rbxassetid://10254751627"
bopSound.PlayOnRemove = true
bopSound.Parent = script
local fruitVal = ingredientInstance
local HRP = plr.Character.HumanoidRootPart
if fruitVal ~= nil then
local char = plr.Character
local HRP = char.HumanoidRootPart
bopSound:Destroy()
local lerpPart = Instance.new("Part", workspace)
lerpPart.Name = "lerpPart"
lerpPart.Position = fruitVal.PrimaryPart.Position + Vector3.new(0, 0, 50)
lerpPart.Color = Color3.fromRGB(0,0,0)
lerpPart.Anchored = true
lerpPart.Massless = true
lerpPart.CanCollide = false
for i = 0, 10, wait() do
local t = i / 10
local l1 = lerp(fruitVal.PrimaryPart.Position, lerpPart.Position, t)
local l2 = lerp(lerpPart.Position, HRP.Position, t)
local quad = lerp(l1, l2, t)
fruitVal.PrimaryPart.Position = quad
task.wait(1)
end
end
end
end)
Add a CFrameValue and set it to the main part’s initial position, you can then lerp said CFrameValue’s value to your destination CFrame. You can either use :SetPrimaryPartCFrame(CFrameValue) with the requirement being the model must has a PrimaryPart, or just set the main part’s CFrame whenever the CFrameValue.Changed event fires.
Here’s an example code:
local mainPart= --Referrence the main part here
local cValue=Instance.new("CFrameValue",mainPart.Parent)
cValue.Value=mainPart.CFrame --Set the CFrameValue's value to the initial position.
local eventConnection;
eventConnection=cValue.Changed:Connect(function(property)
if property=="Value" then
mainPart.CFrame=cValue.Value
end
end)
--eventConnection:Disconnect() to stop updating the part's CFrame. Do this after the lerp has finished.
--Lerp the CFrame value.
Alternatively, you can change it to a Vector3Value and set the main part’s position to the Vector3Value.Value whenever the .Changed event fires if you want only the position being updated.
It works, kinda. What it does is it go to the part then comes to the player really slow. It goes a good speed to the part, then slows down really slow when going to me, Idk why.