-
What do you want to achieve?
I want to make a leaning system (like Rainbow Six Siege) that works flawlessly -
What is the issue?
The actual leaning works but when the player leans, the camera does not follow the player (In the video I zoomed out so you can see the issue, the game will be in first person when it’s done)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried all different things like using couroutine.wrap, the run service, custom camera types. I couldn’t find any existing solutions to this problem
This is my code so far:
local uis = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local rep = game:GetService("ReplicatedStorage")
local eventsFolder = rep:WaitForChild("Events")
local leaningEvent = eventsFolder:WaitForChild("Leaning")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local ti = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine
)
uis.InputBegan:Connect(function(key, isTyping)
if key.KeyCode == Enum.KeyCode.E then
camera.CameraType = Enum.CameraType.Scriptable
leaningEvent:FireServer("Right") -- don't worry about this, this is just for making the head tilt on the server
tweenService:Create(camera, ti, {CFrame = camera.CFrame * CFrame.Angles(0,0,math.rad(-35))}):Play()
elseif key.KeyCode == Enum.KeyCode.Q then
camera.CameraType = Enum.CameraType.Scriptable
leaningEvent:FireServer("Left") -- don't worry about this, this is just for making the head tilt on the server
tweenService:Create(camera, ti, {CFrame = camera.CFrame * CFrame.Angles(0,0,math.rad(35))}):Play()
end
end)
uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
leaningEvent:FireServer("Center", false) -- don't worry about this, this is just for making the head tilt on the server
tweenService:Create(camera, ti, {CFrame = camera.CFrame * CFrame.Angles(0,0,math.rad(35))}):Play()
wait(0.5)
camera.CameraType = Enum.CameraType.Custom
elseif key.KeyCode == Enum.KeyCode.Q then
leaningEvent:FireServer("Center", false) -- don't worry about this, this is just for making the head tilt on the server
tweenService:Create(camera, ti, {CFrame = camera.CFrame * CFrame.Angles(0,0,math.rad(-35))}):Play()
wait(0.5)
camera.CameraType = Enum.CameraType.Custom
end
end)
I know making a leaning system that works the way I want it to is possible since I have seen games on Roblox have it, but after this, I really am confused on how they do it