Shift To Run script not working

Today I was making a script to run a script but I’m having trouble with tweens

LocalScript and the parent is StarterCharacterScripts

--// November/18/2020

--\\ Services

local Players = game:GetService("Players")

local ContextActionService = game:GetService("ContextActionService")

local TweenService = game:GetService("TweenService")

local ReplicatedStorage = game:GetService('ReplicatedStorage')

--// Character

local LocalPlayer = Players.LocalPlayer or Players.PlayerAdded:Wait()

local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()

local Humanoid = Character:FindFirstChildOfClass("Humanoid")

--// Instance

local Animator = Instance.new("Animator")

Animator.Name = "Run"

Animator.Parent = Humanoid

--// Stuff

local Running = false

local CurrentCamera = workspace.CurrentCamera

local Animation = ReplicatedStorage:WaitForChild("PlayerRun")

local RunAnimator = Animator:LoadAnimation(Animation)

--// TweenInfo

local FovInfo = TweenInfo.new(.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)

local WalkSpeedInfo = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)

--// Tweenlocals

local PlayFovTween = TweenService:Create(CurrentCamera,FovInfo, {FieldOfView = 80})

local PlayEndFov = TweenService:Create(CurrentCamera,FovInfo, {FieldOfView = 70})

local PlayWalkSpeed = TweenService:Create(Humanoid,WalkSpeedInfo,{WalkSpeed = 30})

local EndWalkSpeed = TweenService:Create(Humanoid,WalkSpeedInfo,{WalkSpeed = 16})

--// functions

local function IsPlayingTween(Tween)

if Tween.PlaybackState == Enum.PlaybackState.Playing then

Tween.PlaybackState = Enum.PlaybackState.Cancelled

end

end

local function IsPlayingAnimation(self)

if self.IsPlaying then

self:Stop()

end

end

local function BindAction(BindName, InputState)

if InputState == Enum.UserInputState.Begin and BindName == "RunBind" then

Running = true

PlayWalkSpeed:Play()

PlayFovTween:Play()

RunAnimator:Play()

IsPlayingTween(EndWalkSpeed)

IsPlayingTween(PlayEndFov)

IsPlayingTween(PlayEndFov)

elseif InputState == Enum.UserInputState.End and BindName == "RunBind" then

Running = false

EndWalkSpeed:Play()

PlayEndFov:Play()

IsPlayingTween(PlayWalkSpeed)

IsPlayingTween(PlayFovTween)

IsPlayingAnimation(RunAnimator)

end

end

--// Connections

ContextActionService:BindAction("RunBind",BindAction,false,Enum.KeyCode.LeftShift,Enum.KeyCode.ButtonL2)

i found the solution :slight_smile: