-- Services
local UserInputService = game:GetService('UserInputService')
local players = game:GetService('Players')
-- value things
local SprintWalkSpeed = 22
local NormalWalkSpeed = 16
local DoubleTapThreshold = 0.3
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local status = character:WaitForChild("Status")
-- Animation
local runAnimation = character:WaitForChild("Animate").run.RunAnim
local runAnimationTrack = humanoid:LoadAnimation(runAnimation)
-- the player statuses
local lastWPressTime = 0
local isRunning = false
local isInAir = false
#Running script
34 messages · Page 1 of 1 (latest)
-- Helper functions
local function isAnyAttributeTrue(attributes)
for _, attribute in ipairs(attributes) do
if status:GetAttribute(attribute) == true then
return true
end
end
return false
end
local function startRunning()
if not isRunning and not isAnyAttributeTrue({
-- lists of the attributes, change if like you add a new attribute
"Stunned",
"Attacking",
"Blocking",
"Ragdoll",
"M1Value",
}) then
runAnimationTrack:Play()
humanoid.WalkSpeed = SprintWalkSpeed
isRunning = true
end
end
local function stopRunning()
if isRunning then
runAnimationTrack:Stop()
humanoid.WalkSpeed = NormalWalkSpeed
isRunning = false
end
end
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.W then
local currentTime = tick()
local timeSinceLastPress = currentTime - lastWPressTime
local autoRun = status:GetAttribute("AutoRun")
if isAnyAttributeTrue({"Stunned", "Attacking"}) then
stopRunning()
return
end
if autoRun then
startRunning()
elseif timeSinceLastPress <= DoubleTapThreshold then
startRunning()
end
lastWPressTime = currentTime
end
end)
UserInputService.InputEnded:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.W then
stopRunning()
end
end)
local function onStateChanged(_, newState)
if newState == Enum.HumanoidStateType.Freefall or newState == Enum.HumanoidStateType.Jumping then
if not isInAir then
runAnimationTrack:AdjustSpeed(0.2)
isInAir = true
end
elseif newState == Enum.HumanoidStateType.Running or newState == Enum.HumanoidStateType.RunningNoPhysics then
if isInAir then
runAnimationTrack:AdjustSpeed(1)
isInAir = false
end
end
end
humanoid.StateChanged:Connect(onStateChanged)
player.CharacterAdded:Connect(function(newCharacter)
character = newCharacter
humanoid = character:WaitForChild("Humanoid")
status = character:WaitForChild("Status")
runAnimation = character:WaitForChild("Animate").run.RunAnim
runAnimationTrack = humanoid:LoadAnimation(runAnimation)
isRunning = false
isInAir = false
humanoid.WalkSpeed = NormalWalkSpeed
humanoid.StateChanged:Connect(onStateChanged)
end)
couldnt fit the script in one message cause i dont got nitro
not sure if itll work but u can try to check humanoids MoveDirection magnitude to stop the animation
Bro got tsbs map of the toolbox ☠
nah this aint my game
How though
its a other persons game called "tsb concepts"
I feel bad for tsb though
All their assets are in the marketplace
But I can fix yo issue
yea I need help with this issue
So when you hold w and s you don't want the anim to play?
yea
Try put this at the bottom of your script:
game.RunService.Heartbeat:Connect(function()
if humanoid.MoveDirection.Magnitude <= 0 then
runAnimationTrack:Stop()
end
end
Sorry I'm on mobile
It should work
Ok
Does it work?
waiting for the owner to give me a response, sorry for the wait 😭
Ok np
btw, did i do this correctly?
Yup
oh alr
alr so the owner finally answered, had said it didnt work
some reason it still plays the animation'
nah
Ye I honestly don't know