Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
StoIid 364 Moderation Voter
7 years ago

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

Log in to vote
1
Answered by
1N0body 206 Moderation Voter
7 years ago

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)
Ad

Answer this question