Hello, I am having some trouble with the Homing Attack script I recently came up with. I was trying to use tables to index to the script what object should the player teleport to. I used SetPrimaryPartCFrame/PivotTo to teleport because I don't know how to alter a player's CFrame rapidly nor know how to use TweenService. Here is the code:
local targetChangeRate = 1.25
local HM1 = workspace.HomingAttackAble1
local HM2 = workspace.HomingAttackAble2
local HM3 = workspace.HomingAttackAble3
local HM4 = workspace.HomingAttackAble4
local HM5 = workspace.HomingAttackAble5
local AttackbleTable = {
HM1,
HM2,
HM3,
HM4,
HM5
}
local plr = game.Players.LocalPlayer
local Target
while plr do wait(0.05)
pcall(function()
Target = AttackbleTable[1]
local distance = (script.Parent.PrimaryPart.Position - Target.Position).Magnitude
print(distance)
if distance < 50 and script.Parent.Humanoid.Jump == true then
if Target == AttackbleTable[1] then
script.Parent:SetPrimaryPartCFrame(Target.CFrame)
print("LOL")
wait(targetChangeRate)
Target = AttackbleTable[2]
if Target == AttackbleTable[2] then
script.Parent:SetPrimaryPartCFrame(distance - CFrame.new(Vector3.new(0,3,0)))
print("LOL2")
wait(targetChangeRate)
Target = AttackbleTable[3]
if Target == AttackbleTable[3] then
print("LOL3")
end
end
end
end
end)
end
Note: This occurs between the chain of HM1 and HM2 I used the "LOL" prints to see if the things are executing. I only saw "LOL" and not "LOL2" or "LOL3". Thank you for reading.
