How could I make this?

Hi!

How would I be able to make the character face the mouse? Would I use BodyGyro?

See video for reference:

Notice how it only rotates on one axis.

local Game = game
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()

local function OnRenderStep()
	local Pivot = Character:GetPivot()
	Character:PivotTo(CFrame.lookAt(Pivot.Position, Vector3.new(Mouse.Hit.Position.X, Pivot.Position.Y, Mouse.Hit.Position.Z)))
end

RunService.RenderStepped:Connect(OnRenderStep)

Local script.

3 Likes

How would I make it only activate while holding a tool?

By connecting/disconnecting the render stepped connection each time a tool is equipped/unequipped respectively.

I would use Stepped or Heartbeat for this, since you’re manipulating parts that may be affected by physics.

I’d be inclined to agree if the physical instance we were manipulating wasn’t the client’s character.

https://developer.roblox.com/en-us/api-reference/event/RunService/RenderStepped

To avoid this, only use RenderStepped for code that works with the camera or character . Otherwise, RunService.Heartbeat should be used.

1 Like

I learned something new today :slight_smile: