I have a problem with npc. He is doing some really weird things on the server and i dont know if it doesnt break things on client. As you can see the npc should come to you, then wait and jump. Animation on server looks weird too. Sometimes the npc on the client just flies while the npc on server clips through the floor and dies. because of this the pathfinding bugs and i dont really know how to fix it. (These long parts from the sky is random position in radius from the humanoid root part)
All the scripts are on server
local function Fly(self,deltaTime)
self.HRP.Anchored = true
self.target = nil
if not self.FlyAnim.IsPlaying then
self.FlyAnim:Play()
end
self.elapsedTime += deltaTime
local t = self.elapsedTime
local position
if t > 1 then
self.HRP.Position = self.JumpPoint.Position + Vector3.new(0,10,0)
self.HRP.Anchored = false
self.JumpStamina = 50
self.AfterJump = 1000
self.state = "Retreat"
self.FlyAnim:Stop()
self.JumpAnim:Stop()
self.target = self.LastStandingPosition
--position = self.JumpPoint.Position
--connection:Disconnect()
else
position = QuadraticBezier(t, self.LastStandingPosition, self.HRP.Position + Vector3.new(0,5,0), self.JumpPoint.Position + Vector3.new(0,-2,0))
end
--self.HRP.CFrame = CFrame.lookAt(self.HRP.Position,position)
if position then
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {self.Model}
local raycastResult = game.Workspace:Raycast(self.HRP.Position,position - self.HRP.Position,raycastParams)
if raycastResult and raycastResult.Distance <= (position - self.HRP.Position).Magnitude then
self.elapsedTime = 1
--if raycastResult.Instance:IsDescendantOf() then
--end
end
self.HRP.Position = position
end
end
local function Jump(self,ClosestPlayer,deltaTime)
if self.JumpStamina <= 0 then Fly(self,deltaTime) return end
self.target = nil
self.JumpPoint = self.HRP.CFrame:ToWorldSpace(CFrame.new(0,0,-40))
self.state = "Jump"
self.JumpStamina -= 1
self.HRP.CFrame = CFrame.lookAt(self.HRP.Position,Vector3.new(ClosestPlayer.Character.PrimaryPart.Position.X,self.HRP.Position.Y,ClosestPlayer.Character.PrimaryPart.Position.Z))
if not self.JumpAnim.IsPlaying then
self.JumpAnim:Play()
end
end
robloxapp-20240310-1148421.wmv (1.2 MB)
robloxapp-20240310-1148415.wmv (403.9 KB)
here are the videos from the server and client