so, im making a game called “Hammer” and im stuck in this dumb issue.
i want the dummy to fling to where the player head is looking at but
the dummy would not fling to the right direction
the code where the issue is expected
local function touched(h)
h = h.Parent
if isattacking and deb then
deb = false
if h:FindFirstChild("Humanoid") and not h:FindFirstChild("ForceField") then
h.Humanoid:TakeDamage(25)
h.Humanoid.Sit = true
--fling the player(not really)
local bodyvelocity = Instance.new("BodyVelocity")
bodyvelocity.Parent = h.HumanoidRootPart
bodyvelocity.Velocity = CFrame.lookAt(script.Parent.Parent.Head.Position,h.Head.Position).Position -- the part
bodyvelocity.P = 1250
bodyvelocity.MaxForce = Vector3.new(8000,8000,8000)
game:GetService("Debris"):AddItem(bodyvelocity,0.2)
end
end
end
theres an orientation property of humanoid root part that you can change
x = CFrame.lookAt(script.Parent.Parent.Head.Position,h.Head.Position).Position.X
y = CFrame.lookAt(script.Parent.Parent.Head.Position,h.Head.Position).Position.Y
z = CFrame.lookAt(script.Parent.Parent.Head.Position,h.Head.Position).Position.Z
im not quite sure i havent really done anything like this before but perhaps something like that?
what if you made it so when you click the hammer, it walks the player forward slightly but enough to show the change of humanoidrootparts position? and then you keep moving the dummy forward in the same direction that the player first stepped
the player would go forward on a path to the dummy’s humanoid rootpart
anywho i dont really know how to explain it, its as complicated as it sounds
You should never have a .Position when using body velocity since it is just linear velocity, hence; CFrame.lookAt(script.Parent.Parent.Head.Position,h.Head.Position).LookVector * speed You will just need a unit vector for body velocity and other movers but for body position it requires a position.
You can also use something like this without creating a cframe; (h.head.Position-script.Parent.Parent.Head.Position).Unit —the direction goes first then the origin when using .Unit but in .Magnitude it is the reverse.