For some reason when using bezier curves on server side, it seems to be extremely buggy and weird. Anyone got a idea how to fix this?
local RP = game.ReplicatedStorage
local Spit = game.ReplicatedStorage:WaitForChild("Spit")
Spit.OnServerEvent:Connect(function(Player,MousePos)
local SpitPart = Instance.new("Part")
SpitPart.Shape = "Ball"
SpitPart.BrickColor = BrickColor.new("Sea green")
SpitPart.Anchored = false
SpitPart.Parent = game.Workspace
SpitPart.Material = Enum.Material.Neon
SpitPart.Size = Vector3.new(1,1,1)
local Pos1 = Player.Character.Head.CFrame.Position
local Pos3 = MousePos
local MidPoint = (Pos1 + Pos3)/2
local Pos2 = Vector3.new(MidPoint.X,(MidPoint.Y+10),MidPoint.Z)
for i = 0,100,1 do
local Percentage = i/100
local Lerp1 = lerp(Pos1,Pos2,Percentage)
local Lerp2 = lerp(Pos2,Pos3,Percentage)
local Quad = lerp(Lerp1,Lerp2,Percentage)
SpitPart.Position = Quad
task.wait()
end
end)
function lerp(a,b,t)
return a + (b-a) * t
end