You can write your topic however you want, but you need to answer these questions:
-
**What do you want to achieve?
I am attempting to make a shoulder camera that moves when the mouse movement is detected -
**What is the issue?
It stops moving on the x axis if I contentiously move it around trying to do a circle, and the y axis doesnt work properly, I just have it set to a random position on the map to start off with but I am not sure how I should go about it.
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 UIS = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
Mouse.TargetFilter = Character
local MouseTurnSpeedXaxis = 10
local MouseTurnSpeedYaxis = 5
local Mouse_Turn_Speed_X_axis_RIGHT_ForScript = MouseTurnSpeedXaxis * -1
local Mouse_Turn_Speed_X_axis_Left_ForScript = MouseTurnSpeedXaxis
local Mouse_Turn_Speed_Y_axis_UP_ForScript = MouseTurnSpeedYaxis * -1
local Mouse_Turn_Speed_Y_axis_DOWN_ForScript = MouseTurnSpeedYaxis
--local PointPos = workspace.aiming.Position
local PointPos = Vector3.new(0,0,0)
--UIS.MouseBehavior = Enum.MouseBehavior.LockCent
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local lastMouseX, lastMouseY = mouse.X, mouse.Y
local function mouseMoved(actionName, inputState, inputObject)
if inputObject.Delta.X > 0 then
warn("right")
PointPos = PointPos - Vector3.new(Mouse_Turn_Speed_X_axis_RIGHT_ForScript,0,0)
elseif inputObject.Delta.X < 0 then
warn("left")
PointPos = PointPos - Vector3.new(Mouse_Turn_Speed_X_axis_Left_ForScript,0,0)
elseif inputObject.Delta.Y > 0 then
warn("Down")
PointPos = PointPos - Vector3.new(0,Mouse_Turn_Speed_Y_axis_DOWN_ForScript,0)
elseif inputObject.Delta.Y < 0 then
warn("Up")
PointPos = PointPos - Vector3.new(0,Mouse_Turn_Speed_Y_axis_UP_ForScript,0)
end
end
game:GetService("ContextActionService"):BindAction("MouseMoved", mouseMoved, false, Enum.UserInputType.MouseMovement)
local function OnRenderStep()
local MousePosition = Mouse.Hit.Position
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
if workspace.CurrentCamera.CameraType ~= "Scriptable" then
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
end
local char = Character
local charCF = char:GetPrimaryPartCFrame()
local direction = ((PointPos - 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),PointPos)
-- Camera.CFrame = CFrame.Angles(Character:GetPivot() *Vector3.new(2, 4, 13),PointPos.Y,0)
end
RunService.RenderStepped:Connect(OnRenderStep)
Guidence as to what I am doing wrong would help a lot
External Media