You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I am trying to have a shoulder camera where the camera stays put off the players shoulder and focuses on a part.
What is the issue? Include screenshots / videos if possible!
The camera not only doesn’t stay in place to the players torso with the offset, the player is able to walk away out of view.
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local player = Players.LocalPlayer
character = player.CharacterAdded:Wait()
while true do
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
task.wait()
local lockon =character:WaitForChild("UpperTorso").Position+ Vector3.new(-.5,2,-10)
camera.CFrame = CFrame.new(lockon , workspace.aiming.Position)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
end
--
I am not sure why the camera isn’t staying according to where I put the cframe with the offset.
We have to make some adjustments first, change while true do to game[“Run Service”].RenderStepped, which is way better, try fiddling around with the position and offset, stuff like that, currently I have to go, try the things I said above and if you dont find a solution, maybe refer to a roblox developer discord server to help you.
local Game = game
local Workspace = workspace
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Workspace.CurrentCamera
local offset = Vector3.new()
local rootPart = Character:WaitForChild("UpperTorso")
local function OnRenderStep()
local part = workspace.aiming
local char = Character
local charCF = char:GetPrimaryPartCFrame()
local direction = ((part.Position - charCF.Position) * Vector3.new(1,0,1)) + Vector3.new(0, charCF.Position.Y,0)
local newCF = CFrame.lookAt(charCF.Position, charCF.Position + direction, Vector3.new(0,1,0))
char:SetPrimaryPartCFrame(newCF)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(Character:GetPivot() *Vector3.new(2, 4, 13), workspace.aiming.Position)
end
RunService.RenderStepped:Connect(OnRenderStep)