How do I move the player's camera when they do something like slide on the ground?

So I have a sliding script coded but I don’t know how to move the camera down with it, because this game I am making is an FPS, so I want to have camera movement for things like wallrunning and sliding, for example.

How do I code this?

You could use Camera Offset to fix this problem. You could also incorporate tweening to have a smooth transition.

1 Like

That’s a good idea, but how do I code it? I’m not good at that stuff…

Do you mean locking First Person?

If you did, follow below: (also if you get stuck press (Alt+Tab) and again to regain cursor control.

sorry for bad frames i dont have good specs

NOTE: IF YOU APPLY THIS YOU WONT GET A ZOOM-LIKE TRANSITION WHEN THE EVENT TRIGGERS

Since it is a Vector3 value you would do something like this:

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")


Humanoid.CameraOffset = Vector3(0,-2,0) -- Set camera

And if you want to make it look smooth you can look here for examples: Click Here! or look at my example here:

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

TweenService:Create(part, tweenInfo, {Humanoid.CameraOffset = Vector3(0,-2,0)})
1 Like

Where do I put this? I’m getting errors…
Edit: Did I even mention the code yet?

If I didn’t then here it is:

local UIS = game:GetService(“UserInputService”)
local char = script.Parent

local slideAnim = Instance.new(“Animation”)
slideAnim.AnimationId = “rbxassetid://6833904302”

local keybind = Enum.KeyCode.C
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end

if input.KeyCode == keybind then
	canslide = false

	local playAnim = char.Humanoid:LoadAnimation(slideAnim)
	playAnim.Priority = Enum.AnimationPriority.Action
	playAnim:Play()
			
	local slide = Instance.new("BodyVelocity")
	slide.MaxForce = Vector3.new(1,0,1) * 30000
	slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
	slide.Parent = char.HumanoidRootPart
	
	for count = 1, 8 do
		wait(0.1)
		slide.Velocity *= 0.7
	end
	playAnim:Stop()
	slide:Destroy()
	canslide = true
end

end)