can anyone make my script double tap w to run cause i'm not good at this at all here is a script
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local runService = game:GetService("RunService")
local maxStamina = 1000
local staminaRegen = 1
local sprintModifier = 1.5
local sprintStaminaCost = 2
local sprintingPlayers = {}
players.PlayerAdded:Connect(function(player)
local stamina = Instance.new("IntValue", player)
stamina.Value = maxStamina
stamina.Name = "Stamina"
stamina.Changed:Connect(function(property)
replicatedStorage.RemoteEvents.StaminaUpdate:FireClient(player, stamina.Value, maxStamina)
end)
end)
-- Sprint key pressed or released
replicatedStorage.RemoteEvents.Sprint.OnServerEvent:Connect(function(player, state)
local humanoid = player.Character.Humanoid
if state == "Began" and humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics and humanoid.MoveDirection.Magnitude > 0 then
sprintingPlayers[player.Name] = humanoid.WalkSpeed
humanoid.WalkSpeed = humanoid.WalkSpeed * sprintModifier
elseif state == "Ended" and sprintingPlayers[player.Name] then
humanoid.WalkSpeed = sprintingPlayers[player.Name]
sprintingPlayers[player.Name] = nil
end
end)
runService.Heartbeat:Connect(function()
for index, player in pairs(players:GetChildren()) do
local stamina = player.Stamina
local name = player.Name
if not sprintingPlayers[name] then
if stamina.Value > maxStamina then
stamina.Value = maxStamina
elseif stamina.Value < maxStamina then
wait(3)
stamina.Value = stamina.Value + staminaRegen
end
else
if stamina.Value >= sprintStaminaCost then
stamina.Value = stamina.Value - sprintStaminaCost
else
player.Character.Humanoid.WalkSpeed = sprintingPlayers[name]
sprintingPlayers[name] = nil
end
end
end
end)

1 comment
Please do not copy paste scripts and tell people to add to them, learn first and never give up!