so i tried to make a model move to human but it’s just stuck in the middle,
here’s my script:
function(TargetPlayer)
local dirc = char.HumanoidRootPart.CFrame
bone.Bone.Anchored = true
bone.Bone.Locked = true
bone.Bone.CanCollide = false
local hate = false
for i= 0,1, 0.1 do
wait()
local ee = bone:Clone()
ee.Parent = workspace
ee.Bone.Position = Vector3.new(npcToFind.HumanoidRootPart.Position.X,npcToFind.HumanoidRootPart.Position.Y + 9 , npcToFind.HumanoidRootPart.Position.Z)
game:GetService("Debris"):AddItem(ee, 2)
ee.Bone.CFrame = dirc:lerp(ee.Bone.CFrame,0.5)
hate = false
if char.Humanoid.Health <= 0 then
break
end
ee.Bone.Touched:Connect(function(d)
local player = game:GetService("Players"):GetPlayerFromCharacter(d.Parent)
if hate == false then
if player then
player.Character.Humanoid:TakeDamage(2)
hate = true
else
hate = false
end
end
end)
end
return 2
end
If you want a dynamic and overall smoother effect, try using a Rocket Propulsion. Parent it to the bone that you clone, set its target to your target character, and play around with settings. There’s a TargetReached event for it that you can use to deal damage if and when it comes close enough, and then destroy it.
in that case, you can use the for loop you are already using to move it smoothly, However, you should make a variable for the initial CFrame of the bone, to make it more linear move
For example:
local InitialCfm = ee.Bone.CFrame
for i = 0,1,0.1 do
wait()
ee.Bone.CFrame = InitialCfm.lerp(dirc,i)
end
you can also do
dirc:lerp(ee.Bone.CFrame,i)
although if you are doing that, be sure to “reverse the direction” of the for loop, as to not make it go backwards:
local InitialCfm = ee.Bone.CFrame
for i= 1,0, -0.1 do
ee.Bone.CFrame = dirc:lerp(InitalCfm,i)
wait()
end
oh yay it works, sorry for long time not replying , i had to do something, anyway i have another question, how i can make it move alittle bit further and not exactly where humanoid is?