You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want the character’s back to face the player’s camera after pressing the right mouse button, even if the player points their camera down/up -
What is the issue? Include screenshots / videos if possible!
The character’s back doesn’t face the camera; the character just stops rotating, even if i press “a” or “d” to move -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I couldnt find any solution to the problem over the internet
I am new to scripting. I am currently making a “flying” script. Everything works fine, but the character’s back doesnt face the camera.
I only included the part of the script that doesnt work. There are no errors in the output. If you’d like me to send the whole “flying” script, please tell me.
local cam = workspace.CurrentCamera
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local PrimaryPart = char.PrimaryPart
local bg = Instance.new("BodyGyro")
bg.Parent = PrimaryPart
bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bg.D = 10000
bg.Name = "FlightGyro"
---------------------------------------------------
local heartbeat = nil
function LockToCamera()
local camLv = cam.CFrame.lookVector
bg.CFrame = CFrame.lookAt(PrimaryPart.Position, (camLv + PrimaryPart.Position) * 10)
--print((camLv + PrimaryPart.Position) * 10)
--print(camLv + PrimaryPart.Position)
end
uis.InputEnded:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.MouseButton2 and heartbeat) then
heartbeat:Disconnect()
heartbeat = nil
humanoid.AutoRotate = true
end
end)
uis.InputBegan:Connect(function(input, processed)
if processed then return end
if (input.UserInputType == Enum.UserInputType.MouseButton2) and flying then
humanoid.AutoRotate = false
heartbeat = game:GetService("RunService").Heartbeat:Connect(LockToCamera)
end
end)