@ItzBloxyDev Don’t waste peoples time.
There was absolutely nothing wrong with your code. New Roblox updates make CTRL + WASD sort through the Explorer (Who thought we needed this?)
Although nothings wrong with it. I did apply a fix in this code to make it use Shift instead of CTRL when in studio and I moved some stuff around to remove some code lines for better readability and Script Size.
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local PlayerGui = Player:WaitForChild("PlayerGui")
local StaminaGui = PlayerGui:WaitForChild("StaminaGui")
local StaminaOuterFrame = StaminaGui:WaitForChild("StaminaOuterFrame")
local StaminaInnerFrame = StaminaOuterFrame:WaitForChild("StaminaInnerFrame")
local StaminaText = StaminaInnerFrame:WaitForChild("StaminaText")
local Energy = script:WaitForChild("Energy")
local Rate = 0.05
local isRunning = false
local ManStudioSucks = game:GetService("RunService"):IsStudio() and Enum.KeyCode.LeftShift or Enum.KeyCode.LeftControl
-- So explaining this. Lua always uses the last result. So if it is Studio then it will use LeftShift and if it's not studio it's LeftControl.
local PlayerCamera = game.Workspace.CurrentCamera
local OriginalFOV = 70
local SprintingFOV = 80
local function StartBarUpdate()
local UITick
UITick = game:GetService("RunService").RenderStepped:Connect(function()
if Character.Parent == nil or Humanoid.Health == 0 then
UITick:Disconnect()
end
StaminaText.Text = Energy.Value
TweenService:Create(StaminaInnerFrame, TweenInfo.new(0.5 ,Enum.EasingStyle.Linear), {Size = UDim2.new(Energy.Value / 100, 0, 1, 0)}):Play()
end)
return UITick
end
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == ManStudioSucks then
if Energy.Value >= 10 then
isRunning = true
TweenService:Create(Humanoid, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {WalkSpeed = 25}):Play()
TweenService:Create(PlayerCamera, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {FieldOfView = SprintingFOV}):Play()
while isRunning == true do
if isRunning == false then
TweenService:Create(PlayerCamera, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {FieldOfView = OriginalFOV}):Play()
break
elseif Energy.Value <= 10 then
if HRP:FindFirstChild("Speed Sparkles") then
TweenService:Create(Humanoid, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {WalkSpeed = 20}):Play()
TweenService:Create(PlayerCamera, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {FieldOfView = OriginalFOV}):Play()
else
TweenService:Create(Humanoid, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {WalkSpeed = 16}):Play()
end
break
else
Energy.Value -= 1
task.wait(Rate)
end
end
else
return
end
end
end)
UserInputService.InputEnded:Connect(function(input, processed)
if processed then return end
if input.KeyCode == ManStudioSucks then
isRunning = false
if HRP:FindFirstChild("Speed Sparkles") then
TweenService:Create(Humanoid, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {WalkSpeed = 20}):Play()
TweenService:Create(PlayerCamera, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {FieldOfView = OriginalFOV}):Play()
else
TweenService:Create(Humanoid, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {WalkSpeed = 16}):Play()
TweenService:Create(PlayerCamera, TweenInfo.new(0.5, Enum.EasingStyle.Sine), {FieldOfView = OriginalFOV}):Play()
end
while isRunning == false do
if isRunning == true or Energy.Value >= 100 then break end
Energy.Value += 1
task.wait(Rate)
end
end
end)
local UI = StartBarUpdate()
-- If you need to Disconnect UI for some reason, just remove the two lines below.
-- UI:Disconnect()
If this is your first time starting on programming, you’re doing a great job! Keep it up man don’t get lost in boredom land. Get some of that music pumping while making ur awesome stuff.