I tried set the position where it should start(it should start where it is holding the boomerang) from but it didn’t do anything(boomerang slowed down in video)
--NPCAttacking is the Boomeranger
--NPCToAttack is the enemy that the boomeranger is attacking
local H = NPCAttacking.Humanoid
local RangeHeight = H:GetAttribute("RangeHeightMultiplier")
local ProjectilePart = NPCAttacking:FindFirstChild("ProjectilePart")
local PointA
if ProjectilePart then
PointA = NPCAttacking.ProjectilePart.Position
else
PointA = NPCAttacking.HumanoidRootPart.Position
end
local PointB = NPCToAttack.HumanoidRootPart.Position
local Projectile = game.ReplicatedStorage.Items[H:GetAttribute("Projectile")]:Clone()
Projectile.CFrame = CFrame.new(PointA)
Projectile.Parent = workspace.Items
local Speed = H:GetAttribute("RangeSpeed")
local Radius = H:GetAttribute("RangeRadius")
local SpinSpeed = H:GetAttribute("SpinSpeed")
if ProjectilePart then
ProjectilePart.Transparency = 1
end
local Targets = NPCToAttack:FindFirstAncestorWhichIsA("Folder")
local tweenInfo = TweenInfo.new(Speed, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
local hit = {}
local connection = RunService.Stepped:Connect(function()
for i, target in pairs(Targets:GetChildren()) do
local distance = (target.HumanoidRootPart.Position - Projectile.Position).Magnitude
if distance <= Radius and not table.find(hit, target) then
DoDamage(NPCAttacking, target, playerName)
table.insert(hit, target)
end
end
end)
--FOWARD
TW:Create(Projectile, tweenInfo, {Position = PointB}):Play()
local currentElapsedFront = 0
while currentElapsedFront < Speed do
local i = math.min(1, currentElapsedFront/Speed)
currentElapsedFront += RunService.Heartbeat:Wait()
Projectile.CFrame = CFrame.Angles(0, 0, i*SpinSpeed)
end
--BACK
Projectile.CFrame = CFrame.new(PointB)
hit = {} --so u can hit again
TW:Create(Projectile, tweenInfo, {Position = PointA}):Play()
local currentElapsedBack = 0
while currentElapsedBack < Speed do
local i = math.min(1, currentElapsedBack/Speed)
currentElapsedBack += RunService.Heartbeat:Wait()
Projectile.CFrame = CFrame.Angles(0, 0, i*SpinSpeed)
end
--END
connection:Disconnect()
Projectile:Destroy()
local catchAnimTrack = H:LoadAnimation(NPCAttacking.Anims:FindFirstChild("CatchAnim"))
catchAnimTrack:Play()
if H then
if ProjectilePart then
ProjectilePart.Transparency = 0
end
end