Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

humanoid.running function not firing if i walk in a direction for too long?

so the funtion fires if i walk but if i continue walking in that direction for a while it doesnt fire unless i change directions

local human = script.Parent:WaitForChild("Humanoid")
local debounce = false

human.Running:Connect(function()
	if not debounce then
		debounce = true
		wait(script:WaitForChild("Waittime").Value)
		print("TEST")
		script:WaitForChild("Step"):Play()
		local value = Instance.new("StringValue", script.Parent:WaitForChild("Torso"))
		value.Name = "Soundvalue"
		game.Debris:AddItem(value, 3)
		debounce = false
	end
end)

1 answer

✓ Accepted answer

humanoid.Running only fires when the WalkSpeed of the humanoid changes. try using this instead

local human = script.Parent:WaitForChild("Humanoid")
local debounce = false

while humanoid.MoveDirection.Magnitude > 0 do --// Checks if the HumanoidRootPart of the character is moving using the humanoid.MoveDirection
    if not debounce then
        debounce = true
        wait(script:WaitForChild("Waittime").Value)
        print("TEST")
        script:WaitForChild("Step"):Play()
        local value = Instance.new("StringValue", script.Parent:WaitForChild("Torso"))
        value.Name = "Soundvalue"
        game.Debris:AddItem(value, 3)
        debounce = false
    end
end)

1 comment

0

it worked!

This discussion is preserved as it was. New answers, comments, and votes are closed.