Hello there!
Recently, I’ve been working on a Dashing script to use if I ever needed one in games, and, also as practice.
I wanted to implement a Stamina Bar similar to Ultrakill’s.
Then I realized, my small brain doesn’t know how to code one in.
I’m a beginner scripter so I’m not familiar with the things I need and need to frequently visit the documentation for help.
Here’s the script.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local AbletoDash = true
local Time = 0.5
local Multiplier = 130
local StaminaValue = ReplicatedStorage:WaitForChild("StaminaValue").Value
UserInputService.InputBegan:Connect(function(Input, gameProcessedEvent)
if Input.KeyCode == Enum.KeyCode.LeftShift then
if gameProcessedEvent then return end
if StaminaValue ~= 0 then
if AbletoDash then
AbletoDash = false
Character.HumanoidRootPart.Velocity = Character.HumanoidRootPart.CFrame.lookVector*Multiplier Vector3.new(0,20,0)
StaminaValue = StaminaValue - 1
task.wait(Time)
AbletoDash = true
elseif StaminaValue ~= 1 then
if Humanoid.FloorMaterial == Enum.Material.Air then
AbletoDash = false
Character.HumanoidRootPart.Velocity = Character.HumanoidRootPart.CFrame.lookVector*Multiplier Vector3.new(0,20,0)
StaminaValue = StaminaValue - 2
task.wait(Time)
AbletoDash = true
return
end
end
end
end
end)
local function AddStamina()
if StaminaValue < 3 then
StaminaValue = StaminaValue + 1
end
end
while task.wait(1.5) do
print(StaminaValue)
AddStamina()
end
If possible, please put some sort of step-by-step instructions. Even if it’s just a sentence or phrase.
Any amount of help is appreciated.