I’m trying to set up a Bezier curve, and I pretty much have everything down except for the final part of it. I’m getting an error at line 35, which is this line:
-- Variables --
local Remote = game.ReplicatedStorage.Testing.PyraTest
local RunService = game:GetService("RunService")
local P1 = workspace.Bezier1
local P2 = workspace.Bezier2
local P3 = workspace.Bezier3
local LerpDisplay = workspace.BezierLerp
local Intensity = 1
-- Function Variables --
local Speed = .1
local Frames = Speed*60
local InitialCFrame = LerpDisplay.CFrame
local Midpoint = InitialCFrame:Lerp(P3.CFrame,0.5) + Vector3.new(0,Intensity,0)
local RunService = game:GetService("RunService")
local Frame = 0
local Event
local function BLerp(a, b, c)
return a + (b - a) * c
end
local function Lerp()
Frame = Frame + 1
print(Frame)
local Alpha = Frame/Frames
local L1 = BLerp(LerpDisplay.CFrame.p,Midpoint.p,Alpha)
local L2 = BLerp(LerpDisplay.CFrame.p,P3.CFrame.p,Alpha)
LerpDisplay.CFrame.p = InitialCFrame.p:Lerp(L1, L2, Alpha)
if Frame >= Frames then
print ("Frames Reached.")
Event:Disconnect()
end
end
Event = RunService.Stepped:Connect(Lerp())
Remove the double quotes. You are effectively telling Roblox to connect .Stepped to nil, because Lerp() is “replaced” with what the Lerp function returns, which is nothing, instead of the function itself.
The error is caused by the fact that :Lerp only takes 2 arguments, the end position and the alpha. The only time it will take 3 arguments if you change out the colon for a period, so Position.Lerp() instead of Position:Lerp(). Though, the 2nd and 3rd arguments are the same as the 1st and 2nd arguments you’d use for :Lerp and the 1st argument is just the starting position.
So, it looks like you mistook what Lerp does. It just moves the position from the start to the end, and breaks if you give it any middle points. From the looks of it, you should replace InitialCFrame.p:Lerp with BLerp(InitialCFrame.p, L1, L2).
That ended up working and getting rid of the error message, but now a new problem popped up. The LerpDisplay block showing the position of the lerp on the Bezier curve goes of randomly into the middle of nowhere.
When I zoom into the part, it’s all the way out from my part, somewhere it shouldn’t be.