What do you want to achieve?
hello, I’m trying to make a movement system using a tweened CFrame, for an NPC (a boss that’ll chase a player)
What is the issue?
when the player is standing still the boss would teleport underneath the player or out the map somewhere or even when the player is above something the Npc would act up by teleporting underneath the map and or above the player
What solutions have you tried so far?
I’ve got some help from looking at some dev forums posts but other than that i did it solo.
local StartAnimationForJeff3 = character.Humanoid:LoadAnimation(
script.Parent.Parent.AnimationList.StartAnimations.AnimationThree)
local NumberOfAttacks = 0
StartAnimationForJeff3:Play()
StartAnimationForJeff3:Stop()
local function Attackone()
if #PlayersInBossFight ~= 0 then
Attackmodule.RandomPlayer()
repeat
task.wait(1)
local info = TweenInfo.new(0.7, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)
local goals = {Position = Vector3.new(RandomPlayer.Character.PrimaryPart.Position.X, character.Parent.Middle.Position.Y, RandomPlayer.Character.PrimaryPart.Position.Z);}
local movingtolocation = TweenService:Create(character.PrimaryPart, info, goals)
movingtolocation:Play()
local info = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)
local goals = {CFrame = CFrame.lookAt(character.PrimaryPart.Position, Vector3.new(RandomPlayer.Character.PrimaryPart.Position.X, character.Parent.Middle.Position.Y, RandomPlayer.Character.PrimaryPart.Position.Z));}
local lookat = TweenService:Create(character.PrimaryPart, info, goals)
lookat:Play()
movingtolocation.Completed:Connect(function()
StartAnimationForJeff3:Play()
task.wait(2)
NumberOfAttacks = NumberOfAttacks + 1
end)
until NumberOfAttacks ~= 6
StartAnimationForJeff3:Play()
StartAnimationForJeff3:Stop()
end
end
local AttackoneFunction = coroutine.wrap(Attackone)
AttackoneFunction()
Do not put “Y” position, this can cause various problems in the vertical system. Well I removed them so try using this code of mine:
As a reminder that if the “Enemy” wants to follow the player up a ladder then this will not give him any problem.
local StartAnimationForJeff3 = character.Humanoid:LoadAnimation(
script.Parent.Parent.AnimationList.StartAnimations.AnimationThree)
local NumberOfAttacks = 0
StartAnimationForJeff3:Play()
StartAnimationForJeff3:Stop()
local function Attackone()
if #PlayersInBossFight ~= 0 then
Attackmodule.RandomPlayer()
repeat
task.wait(1)
local info = TweenInfo.new(0.7, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)
local goals = {Position = Vector3.new(RandomPlayer.Character.PrimaryPart.Position.X, 0, RandomPlayer.Character.PrimaryPart.Position.Z);}
local movingtolocation = TweenService:Create(character.PrimaryPart, info, goals)
movingtolocation:Play()
local info = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)
local goals = {CFrame = CFrame.lookAt(character.PrimaryPart.Position, Vector3.new(RandomPlayer.Character.PrimaryPart.Position.X, 0, RandomPlayer.Character.PrimaryPart.Position.Z));}
local lookat = TweenService:Create(character.PrimaryPart, info, goals)
lookat:Play()
movingtolocation.Completed:Connect(function()
StartAnimationForJeff3:Play()
task.wait(2)
NumberOfAttacks = NumberOfAttacks + 1
end)
until NumberOfAttacks ~= 6
StartAnimationForJeff3:Play()
StartAnimationForJeff3:Stop()
end
end
local AttackoneFunction = coroutine.wrap(Attackone)
AttackoneFunction()