Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help making a script make your character face forward while right click is down?

I am trying to make a script that makes your character face forwards when right click is down, also when u turn, your character turns too.

Here is a visual of what I am trying to make

Visual Example

As you can see someone has made this before by someone so I am trying to make it for myself. If you guys can make it for me that'd be AWESOME, also leading me in the right direction on how to make this would be greatly appreciated aswell.

1 answer

Trick here is the CameraType = Enum.CameraType.Attach, you connect it to an InputBegan function, and switch it back to Enum.CameraType.Custom, on InputEnded.

In a localscript

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local inputService = game:GetService('UserInputService')

inputService.InputBegan:connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
	camera.CameraType = Enum.CameraType.Attach
	end
end)
inputService.InputEnded:connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
	camera.CameraType = Enum.CameraType.Custom
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.