basically i want this script to also move the player’s character with the camera so it faces the same direction. this will be used to aim a bow and arrow any help is much appreciated thank you THIS IS MY SCRIPT in StarterCharacterScripts
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local focusing = false
UserInputService.InputBegan:Connect(function(input)
if (input.KeyCode == Enum.KeyCode.F) then
if focusing == true then
focusing = false
humanoid.CameraOffset = Vector3.new(0, 0, 0)
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
else
focusing = true
humanoid.CameraOffset = Vector3.new(4, 1, 0)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
end
end
end)
while game:GetService("RunService").RenderStepped:Wait() do
if focusing == true then -- if the aim cam is enabled
--i would think the code for that would go in a RenderStepped event
end
end
THIS IS WHAT I HAVE SO FAR
the camera moves with the mouse
the character is offset to the left
enable or disable with “f” key, i will add a mobile button and xbox button later
i have already tried many fourm posts and also the official over the shoulder cam script/tutorial by roblox and that must have been outdated. it did not work but some of the code did which i used here
this is the script from roblox. i don’t understand most of it Scripting the Camera
THIS IS AN EXAMPLE OF WHAT I MEAN BY THE CHARACTER MOVING WITH THE CAMERA this is from “islands”
local players = game:GetService("Players")
local runservice = game:GetService("RunService")
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
local humanoid = character.Humanoid
local camera = workspace.CurrentCamera
local MAX_LENGTH = 900000
local active = false
local ENABLED_OFFSET = CFrame.new(1.7, 0, 0)
local DISABLED_OFFSET = CFrame.new(-1.7, 0, 0)
local function UpdateAutoRotate(BOOL)
humanoid.AutoRotate = BOOL
end
local function GetUpdatedCameraCFrame(ROOT, CAMERA)
return CFrame.new(root.Position, Vector3.new(CAMERA.CFrame.LookVector.X * MAX_LENGTH, root.Position.Y, CAMERA.CFrame.LookVector.Z * MAX_LENGTH))
end
local function EnableShiftlock()
UpdateAutoRotate(false)
root.CFrame = GetUpdatedCameraCFrame(root, camera)
camera.CFrame = camera.CFrame * ENABLED_OFFSET
end
local function DisableShiftlock()
UpdateAutoRotate(true)
camera.CFrame = camera.CFrame * DISABLED_OFFSET
pcall(function()
active:Disconnect()
active = nil
end)
end
active = false
function ShiftLock()
if not active then
active = runservice.RenderStepped:Connect(function()
EnableShiftlock()
end)
else
DisableShiftlock()
end
end
local ShiftLockButton = CAS:BindAction("ShiftLOCK", ShiftLock, false, "On")
CAS:SetPosition("ShiftLOCK", UDim2.new(0.8, 0, 0.8, 0))
UIS.InputEnded:Connect(function(Key, istyping)
if not istyping then
if Key.KeyCode == Enum.KeyCode.F then
if not active then
active = runservice.RenderStepped:Connect(function()
EnableShiftlock()
end)
else
DisableShiftlock()
end
end
end
end)