I want to play an animation playing when Shift is being hold, and when you release it. The animation stops. How do I add it in here, and also the script only works in studio, but not in roblox client. z_z Help fix! Take a look below.
if script.Parent.Name == "PlayerGui" then local mouse = game.Players.LocalPlayer:GetMouse() local running = false local gui = script.sprntGui.Frame energy = 100 mouse.KeyDown:connect(function (key) -- Run function key = string.lower(key) if string.byte(key) == 48 then running = true local keyConnection = mouse.KeyUp:connect(function (key) if string.byte(key) == 48 then running = false end end) for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (70+(i*2)) wait() end game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30 repeat wait() if energy ~= 20 then gui.Size = gui.Size-UDim2.new(0,5,0,0) energy = energy-1 else running = false end until running == false keyConnection:disconnect() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (80-(i*2)) wait() end coroutine.resume(coroutine.create(function() repeat wait() if energy ~= 100 then gui.Size = gui.Size+UDim2.new(0,5,0,0) energy = energy+1 end until running == true end)) end end) else print("YOU MUST PUT THIS INSIDE STARTGUI") end