local Player = game.Players.EekPlayz09.Character.Head
local eHRP
for i, v in pairs(game.Players:GetChildren()) do
if v.Name ~= Player.Parent.Name then
eHRP = v.Character
end
end
local Hight = math.abs((eHRP["Left Leg"].Position.Y - eHRP.Head.Position.Y))
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {eHRP.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local raycastResult = workspace:Raycast(eHRP.Head.Position, Vector3.new(0, -(Hight* 2), 0), raycastParams)
local Distance
if raycastResult then
Distance = (game.Players.EekPlayz09.Character.Head.Position - eHRP.Head.Position).magnitude
else
Distance = (game.Players.EekPlayz09.Character.Head.Position - eHRP["Left Leg"].Position).magnitude
end
local LookAt = Player.Parent.Torso.CFrame:PointToWorldSpace(Vector3.new(0,0, -3)):lerp(eHRP.Torso.Position, .1)
Player.Parent.Torso.CFrame = CFrame.lookAt(Player.Parent.Torso.Position, LookAt, Player.Parent.Torso.CFrame.UpVector)
print(Distance)
if Distance < 25 then
spawn(function()
if Distance < 23 then
Player.Parent.Torso.Anchored = true
wait(0.2)
Player.Parent.Torso.Anchored = false
Player.Parent.Humanoid:ChangeState(Jump)
end
end)
local Force = Instance.new("BodyVelocity", eHRP.HumanoidRootPart)
Force.MaxForce = Vector3.new(0.5,0.3,0.5) * math.huge
local Direction = (eHRP.HumanoidRootPart.CFrame.Position - game.Players.EekPlayz09.Character.HumanoidRootPart.CFrame.Position).Unit
Force.Velocity = Vector3.new(Direction.X, 0.4, Direction.Z) * 20
game.Debris:AddItem(Force, .44)
local LoadedAnim = game.Players.EekPlayz09.Character.Humanoid:LoadAnimation(game.StarterPack.Sword.Handle.LocalScript.AnimationR15)
LoadedAnim:Play()
local SelectionBox = Instance.new("SelectionBox")
SelectionBox.Parent = eHRP
SelectionBox.Adornee = eHRP
SelectionBox.Color3 = Color3.new(255, 0, 0)
game.Debris:AddItem(SelectionBox, 0.4)
wait(0.5)
If they are unable to move, I would recommend just using Align Orientation to fix your problem. Align orientation uses CFrames, however, it doesnt stunt the players movement… This could be helpful.
local model = Player.Parent.Torso
local reference = eHRP.Torso
local cframe = CFrame.lookAt(model.Position, reference.Position)
align_orientation.CFrame = cframe
local playerPos = Player.Character:GetPivot().Position -- Get current character CFrame.Position
local ehrp = eHRP.Torso
Player.Character:PivotTo(CFrame.lookAt(playerPos, ehrp.Position)) -- Use CFrame.lookAt to orient the character to face ehrp