So I was reading up on Cubic and looking at models and I decided to make my own. Everything is going well but I come across this error; " ServerScriptService.CubicScript:33: attempt to perform arithmetic (add) on Vector3 and Instance - Server - CubicScript:33 " Im not sure how to solve this.
local CubicFire = game.ReplicatedStorage.CubicFire
local RunService = game:GetService("RunService")
function lerp(a, b, c)
return a + (b - a) * c
end
function cubicBezier(t, p0, p1, p2, p3)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local l3 = lerp(p2, p3, t)
local a = lerp(l1, l2, t)
local b = lerp(l2, l3, t)
local cubic = lerp(a, b, t)
return cubic
end
CubicFire.OnServerEvent:Connect(function(Player, Mouse)
local Character = Player.Character
local Root = Character:WaitForChild("HumanoidRootPart")
local Start = os.clock()
local Part = game.ReplicatedStorage.Part:Clone()
Part.Parent = workspace
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(1,1,1)
Part.CFrame = Root.CFrame
local StartPosition = (Root.CFrame * CFrame.new(0,0,-5)).Position
local Position3 = Mouse
local Position1 = (StartPosition + Position3)/2 + Vector3.new(0,math.random(20,50),0)
local Position2 = Position1 + Vector3.new(math.random(-40,40),0,math.random(-40,50))
local Render; Render = RunService.Heartbeat:Connect(function()
local End = os.clock() - Start
Part.CFrame = CFrame.new(cubicBezier(End, StartPosition, Position1, Position2, Position3))
if (End > 1) then
Render:Disconnect()
Part:Destroy()
end
end)
end)