Dear Developers,
Today I was trying to make a player crouching animation when pressed a certain button, when I tested it everything was working fine, there is just one thing that is annoying that pretty much breaks the entire point of the script.
Is it somehow possible to make the camera follow the motion of the animation when the player is in First Person the entire time?
local uis = game:GetService("UserInputService")
local crawlAnimation = script:WaitForChild("Crouch")
local loadedCrouchAnim
local crawlIdle = script:WaitForChild("CrouchIdle")
local loadedIdleAnim
local isCrouching = false
local humanoid = script.Parent:FindFirstChild("Humanoid")
uis.InputBegan:Connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift then
if isCrouching then
isCrouching = false
if loadedCrouchAnim then loadedCrouchAnim:Stop() end
loadedIdleAnim:Stop()
game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 18, 40)
elseif not isCrouching then
isCrouching = true
loadedIdleAnim = humanoid:LoadAnimation(crawlIdle)
loadedIdleAnim:Play()
game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 5, 30)
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if not isCrouching then return end
if humanoid.MoveDirection.Magnitude > 0 then
if not loadedCrouchAnim then loadedCrouchAnim = humanoid:LoadAnimation(crawlAnimation) end
if loadedCrouchAnim.IsPlaying == false then loadedCrouchAnim:Play() end
else
loadedCrouchAnim:Stop()
loadedIdleAnim:Play()
end
end)