Like the title asked.
UserInputService.InputBegan:connect(function(input, event) if event then return end if event then return end if input.KeyCode == Enum.KeyCode.W then if not start then start = tick() else if tick() - start < 0.2 then start = false if Running == false then print("Running") Running = true game.ReplicatedStorage.RemoteEvents.StartRunEvent:FireServer() current:Play() local RandomNumber = math.random(0, 1) if RandomNumber == 1 then Player.Data.AgilityEXP.Value = Player.Data.AgilityEXP.Value+math.random(5, 8) Player.Backpack.PlayerSetup.CombatSystem.Disabled = true end end else start = tick() --reset counter end end end end) UserInputService.InputEnded:connect(function(input, event) if input.KeyCode ~= Enum.KeyCode.W then return end; if Running == true then print("Walking") Running = false game.ReplicatedStorage.RemoteEvents.StopRunEvent:FireServer() current:Stop() Player.Backpack.PlayerSetup.CombatSystem.Disabled = false end end)
Is there also a way i can make it where a stamina bar goes down when the player is sprinting with this script?
You have to create a variable that is not in the script like a string value and just change is number with simple math.And then you will have your stamine value.
For a basic UI bar make a script that is changing the size of the bar depending on the value of the stamina Variable that you created.