I already figured that the way to do it would be using a remote event, but that’s where the problem is.
My code looks for the position of the mouse constantly until the player lets go of m1:
Termination = RunService.Heartbeat:Connect(function()
if player.Character then
if player.Character.HumanoidRootPart then
player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position + Mouse.Hit.LookVector)
end
end
if not On then
Termination:Disconnect()
end
end)
I fear that using remote events constantly wouldn’t be a good idea at all, as that would mean that there could possibly be many hundreds of them fired per second in one server in a matter of seconds.
I can’t do it locally because it doesn’t show the player turning on the server side, so other players can’t see where the player is aiming their attack.
You could still use RemoteEvents, just add a cooldown on the client so it doens’t fire too often.
local lastUpdate = 0
Termination = RunService.Heartbeat:Connect(function()
local now = os.clock()
if player.Character and (now - lastUpdate) > .5 then
lastUpdate = now
if player.Character.HumanoidRootPart then
player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position + Mouse.Hit.LookVector)
end
end
if not On then
Termination:Disconnect()
end
end)