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 to make an OTS camera for a weapon system I’m developing but the player movement isn’t working properly when the camera is set. -
What is the issue? Include screenshots / videos if possible!
Character doesn’t walk straight backwards, script and video are attached.
Walking mechanic - Clipped with Medal.tv
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local UserInput = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local storage = game.ReplicatedStorage.PikeStorage
local camera = game.Workspace.CurrentCamera
local tool = script.Parent
local XAngle = 0
local YAngle = 0
local tweeninfo = TweenInfo.new(
.1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
repeat wait() until player.Character
local root = player.Character.HumanoidRootPart
UserInput.InputChanged:connect(function(input)
trackInput(input)
end)
function trackInput(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
XAngle = XAngle - input.Delta.X * .4
YAngle = math.clamp(YAngle - input.Delta.Y * .4, -80, 80)
end
end
local function Camera(delta)
local NewCF = CFrame.new(root.CFrame.Position, root.CFrame.Position + Vector3.new(camera.CFrame.LookVector.X, 0, camera.CFrame.LookVector.Z))
local CameraOffset = Vector3.new(3.5,0,6)
local StartCFrame = CFrame.new((root.CFrame.Position + Vector3.new(0, 2, 0))) * CFrame.Angles(0, math.rad(XAngle), 0) * CFrame.Angles(math.rad(YAngle), 0, 0)
local CameraCFrame = StartCFrame + StartCFrame:VectorToWorldSpace(Vector3.new(CameraOffset.X, CameraOffset.Y, CameraOffset.Z))
local CameraFocus = StartCFrame + StartCFrame:VectorToWorldSpace(Vector3.new(CameraOffset.X, CameraOffset.Y, -50000))
local Offset = CFrame.new(CameraCFrame.p, CameraFocus.p)
camera.CFrame = Offset
TS:Create(root,tweeninfo, {["CFrame"] = NewCF}, true):Play()
end
tool.Equipped:connect(function()
storage.equipWeld:FireServer(tool)
camera.CameraType = "Scriptable"
RS:BindToRenderStep("Camera",0,function(delta)
UserInput.MouseBehavior = Enum.MouseBehavior.LockCenter
Camera(delta)
end)
end)
tool.Unequipped:connect(function()
RS:UnbindFromRenderStep("Camera")
camera.CameraType = "Custom"
UserInput.MouseBehavior = Enum.MouseBehavior.Default
end)
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Tried messing around with shift lock and camera types but nothing’s really come out as working.
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.