I am trying to stop the Animation after the input ends, but it does not work. Can someone please help me?
this is the only error Im getting
Also, please note that im a beginner, so please forgive me if it was a simple mistake
Here is the script: (Client Sided script)
local PLAYR_character = GAME_LOCAL_PLAYER.character
local PLAYER_Humanoid = GAME_LOCAL_PLAYER.character.Humanoid
local PLAYER_CURRECT_CAM = workspace.CurrentCamera
local GAME_REPLICATED_STORAGE = game:GetService("ReplicatedStorage")
local USER_INPUT_SERVICE = game:GetService("UserInputService")
--MISC_VARIABLES
local LEFT_CONTROL_IS_HELD = false
local PLAYER_INCREASE_SPEED = 17
local CLIENT_SERVER_CONNECT = game.ReplicatedStorage:WaitForChild("ClientServerAccessor")
--INPUT_CODE
local function sprintHasBegun(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl then
local PlayerFOV = 70
local Goals = {FieldOfView = PlayerFOV + 30}
local CameraZoomTweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local zoomTween = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, CameraZoomTweenInfo, Goals)
zoomTween:Play()
local PLAYER_SPRINTING_ANIMATION = Instance.new("Animation")
PLAYER_SPRINTING_ANIMATION.AnimationId = 'rbxassetid://7437837668'
local PLAYER_ANIMATION_TRACK_PLAYER = PLAYER_Humanoid.Animator:LoadAnimation(PLAYER_SPRINTING_ANIMATION)
PLAYER_ANIMATION_TRACK_PLAYER:Play()
LEFT_CONTROL_IS_HELD = true
game.ReplicatedStorage.ClientServerAccessor:FireServer(GAME_LOCAL_PLAYER)
end
end
end
--INPUT_ENDED_CODE
local function sprintHasEnded(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl and LEFT_CONTROL_IS_HELD == true then
PLAYER_CURRECT_CAM.FieldOfView = 80
PLAYER_ANIMATION_TRACK_PLAYER:Stop() -- Highlighted in red
game.ReplicatedStorage.SprintHasEnded:FireServer(GAME_LOCAL_PLAYER)
end
end
end
USER_INPUT_SERVICE.InputBegan:Connect(sprintHasBegun)
USER_INPUT_SERVICE.InputEnded:Connect(sprintHasEnded)
--