Hello people,
I have an issue with the boss that I’m making for my game.
The boss has a “Jump” attack which I have scripted which makes the boss jump from any part of the map at a random player. Now the attack works fine and there isn’t an issue with the attack itself, but after the attack, the boss starts glitching around while walking.
Here is the function which triggers the attack:
local function startJumpAttack(target)
local playerHumanoid = target:FindFirstChild("Humanoid")
local playerRoot = target:FindFirstChild("HumanoidRootPart")
local player = Players:GetPlayerFromCharacter(target)
if not player or not playerHumanoid or not playerRoot or playerHumanoid.Health <= 0 then return end
isAttacking = true
HumanoidRootPart.Anchored = true
LoadedJump:Play()
LoadedWalk:Stop()
LoadedIdle:Stop()
LoadedJump:GetMarkerReachedSignal("GroundSlam"):Wait()
HumanoidRootPart.GroundSlam:Play()
LoadedJump:GetMarkerReachedSignal("Jump"):Wait()
HumanoidRootPart.Jump:Play()
local targetPosition = playerRoot.Position + Vector3.new(0, 2, 0)
local bossStartPosition = HumanoidRootPart.Position
local jumpHeight = 50
local midPoint = Vector3.new(
(bossStartPosition.X + targetPosition.X) / 2,
math.max(bossStartPosition.Y, targetPosition.Y) + jumpHeight,
(bossStartPosition.Z + targetPosition.Z) / 2
)
local ascendTween = TweenService:Create(HumanoidRootPart, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
Position = midPoint
})
ascendTween:Play()
ascendTween.Completed:Wait()
local descendTween = TweenService:Create(HumanoidRootPart, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {
Position = targetPosition
})
descendTween:Play()
descendTween.Completed:Wait()
HumanoidRootPart.Position = targetPosition
HumanoidRootPart.GroundLand:Play()
HumanoidRootPart.Velocity = Vector3.zero
HumanoidRootPart.RotVelocity = Vector3.zero
HumanoidRootPart.Anchored = false
LoadedJump.Stopped:Wait()
LoadedIdle:Play()
isAttacking = false
end
And here is the code which handles these attacks and the movement:
local function main()
HumanoidRootPart:SetNetworkOwner(nil)
local closestTarget = findClosestTarget()
if closestTarget == nil then return end
local playerHumanoid = closestTarget:FindFirstChild("Humanoid")
local playerRoot = closestTarget:FindFirstChild("HumanoidRootPart")
if not playerHumanoid and not playerRoot and playerHumanoid.Health <= 0 then return end
if requiresPathfinding(playerRoot) == true then
local calculatedPath = CalculatePath(HumanoidRootPart.Position, playerRoot.Position)
if calculatedPath == nil then return end
walkPath(calculatedPath, closestTarget)
else
Humanoid:MoveTo(playerRoot.Position)
end
local distanceToPlayer = ((HumanoidRootPart.Position - Vector3.new(0, 4, 0)) - playerRoot.Position).magnitude
if distanceToPlayer < 7 then
startAttack(closestTarget)
end
local currentStunAttack = tick()
if distanceToPlayer > 10 and currentStunAttack - lastStunAttack >= stunAttackDebounce then
lastStunAttack = currentStunAttack
startStunAttack()
end
local currentJumpAttack = tick()
if distanceToPlayer > 15 and currentJumpAttack - lastJumpAttack >= jumpAttackDebounce then
lastJumpAttack = currentJumpAttack
local chosenPlayer = getRandomLivingPlayer()
if chosenPlayer ~= nil then
startJumpAttack(chosenPlayer.Character)
end
end
end
Here’s a video, as you can see, the boss keeps slightly teleporting around and the close attack completely breaks the player which doesn’t happen before the jump attack.
Here you can see it glitching horribly: