How to make the move replicate my orientation too?

I want this script to make my character turn towards the mouses target when the ability move is held down so you can aim before releasing “E”
I think I may know how, but I’m bad with Vector Values ect…

local script:

local tool = script.Parent
local UIP = game:GetService("UserInputService")
local Remote = tool:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer

local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local Debounce = 1
local anim = script.Animation

local track = char.Humanoid:LoadAnimation(anim)
local ic = script.InstaCast
local Tool = script.Parent
local toolquip = false

local function Equipped()
	print(". . . Detected Equip")
toolquip = true
end

local function UnEquipped()
    print(" . . . Detected Unequip")
toolquip = false
end

Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(UnEquipped)
UIP.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and toolquip == true then
		print("Local Script Recieved Input . . .")
		Debounce = 2
		spawn(function()

		ic = true
		wait(0.41)
		ic = false
			
		end)
		root.Anchored = true
		track:Play()
		wait(0.15)
		track:AdjustSpeed(0)
	end
end)

UIP.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 2 then
		repeat wait() until ic == false
		print(". . . Sending To Server")
		track:AdjustSpeed(1)
		Debounce = 3
		Remote:FireServer(char, player, UIP, tool)
		print(". . . SENT . . .")
		wait(4) -- cooldown
		Debounce = 1
	end
end)

server script:

local remote = script.Parent.Parent.RemoteEvent
local replicated =  game:GetService("ReplicatedStorage")
local Modules = game.ReplicatedStorage.Modules
local misc = require(Modules.Misc)

remote.OnServerEvent:Connect(function(player, char, tool)
	print("Server Recieved Call From Client . . . Initiating")


	local explosion = replicated.FX.template2:Clone()

	local hrp = char:WaitForChild("HumanoidRootPart")

	hrp.Anchored = true

	explosion.Parent = workspace

	explosion.CFrame = CFrame.new((hrp.CFrame*CFrame.new(0, 0, 0)).Position)

	local hitList = {}

	explosion.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local hitChar = hit.Parent --the character associated with the hit part

			if hitChar == char or hitList[hitChar] then return end --dont damage if hitChar is you or if hitChar has already been hit

			hitList[hitChar] = true --record that hitChar has been hit

			hitChar.HumanoidRootPart.CFrame = CFrame.lookAt(hitChar.HumanoidRootPart.Position, explosion.Position) * CFrame.Angles(0, math.pi, 0)

			local Damage = 50 -- Damage Amount
			hitChar.Humanoid:TakeDamage(Damage)
			misc.StrongKnockback(hit.Parent.HumanoidRootPart, 35, 45, 0.15, explosion)
		end
	end)

	wait(2)
	hrp.Anchored = false
	explosion:Destroy()
print("Operation Finished")
end)

Are you experiencing a problem currently, or you looking for some code?

My problem is that I couldn’t find a tutorial or a explanation anywhere on how I would exactly do this.

1 Like