# Discrepancy Between Client and Server for lunge attack

So I was creating a lunging attack for an enemy, in which I used a bezier curve to move it as it plays an animation. However while in testing I noticed some odd behavior from the enemy after the attack finished. Turns out there is a discrepancy between the the client, and what is happening on the server. Note that the server is incorrect in this case. All the code for the attack is running on the server and can be seen here:

``````--make braizer curve between target position and model
local function quadBezier(t, p0, p1, p2)
return (1 - t)^2 * p0 + 2 * (1 - t) * t * p1 + t^2 * p2
end
local function getP1(a, b) --this makes a midPoint for the bezier at a height based on theta
local distance = (a-b).Magnitude
local midPoint = a:Lerp(b, 1/2)
local h = distance/(2*math.tan(theta/2))
local vector = midPoint + Vector3.new(0,h,0)
return vector
end
local points = {}
local b = getP1(model.PrimaryPart.Position, info.target.PrimaryPart.Position+Vector3.new(0,3,0))
for i = 1, 21 do
points[#points+1] = quadBezier(i/21, model.PrimaryPart.Position+Vector3.new(0,3.5,0), b, info.target.PrimaryPart.Position+Vector3.new(0,3.5,0))
end
--move model along braizer while animation plays
local move
move = meleeAnimTrack:GetMarkerReachedSignal("SwingStart"):Connect(function()
local hit = {}
for i, v in ipairs(points) do
model.PrimaryPart.Position = v
--damage players who are to close to the model
for index, player in ipairs(info.PlayerList) do
if playerInRangeOf(MELEE_RANGE, player, model.PrimaryPart.Position) and not hit[player] then
player.Character:WaitForChild("Humanoid"):TakeDamage(10)
hit[player] = true
end
end
wait()
end
move:Disconnect()
end)
meleeAnimTrack:Play()
``````

Client:
Forum keeps turning the gif into a jpeg, so ill just describe it. Enemy arcs towards player and is doing the completely expected behavior.

Server:
Forum keeps turning the gif into a jpeg, so ill just describe it. Enemy begins its animation, but when it should start arcing toward the player with the bezier it just sinks into the ground. Once the bezier is done roblox physics goes crazy as a collidable part is inside another collidable part.

I am thinking this some sort of weird interaction between physics, animations, and positioning, but I’m not really sure how to tackle it, as I am not well versed in roblox physics.