I’m creating a boss fight which the enemy plays an animation, waits for a marker to get reached, “Attack”, and then jumps in the direction of its look vector. During the period of time waiting for the marker to be reached, there’s a loop which has the enemy look at the player so when it’s ready to jump, it jumps towards the player. Here’s my script
spider.PrimaryPart.Anchored = true
local attackAny_FINISHED = false
local tween
attackAny:GetMarkerReachedSignal("Done looking"):Connect(function()
attackAny_FINISHED = true
end)
repeat task.wait()
if tween == nil then
tween = game:GetService("TweenService"):Create(spider.PrimaryPart, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {CFrame = CFrame.lookAt(spider.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position)})
tween:Play()
tween.Completed:Wait()
end
spider:SetPrimaryPartCFrame(CFrame.lookAt(spider.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position + -(player.Character.HumanoidRootPart.CFrame.LookVector * 10)))
until attackAny_FINISHED == true
spider.PrimaryPart.Anchored = false
wait(0.1)
spidHumanoid.WalkSpeed = (spider.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude + 30
spidHumanoid:MoveTo(player.Character.HumanoidRootPart.Position + (spider.HumanoidRootPart.CFrame.LookVector * 2))
activeAttackDamage = 20
attackAny:GetMarkerReachedSignal("Done"):Wait()
activeAttackDamage = 0
repeat task.wait() until attackAny.IsPlaying == false
First of all the tween doesn’t seem to work.
Second of all the enemy looks at the players position but I want to find another, more efficient, way of doing this as the enemy is falling behind from the players position.