Humanoid.Running runs whenever I equip a tool. but the speed seems to be the same as before?
I want to know why that happens and how to avoid the Humanoid.Running to run whenever I equip a tool.
Humanoid.Running runs whenever I equip a tool. but the speed seems to be the same as before?
I want to know why that happens and how to avoid the Humanoid.Running to run whenever I equip a tool.
Hi! From what you’ve written in your questions, I cannot really know what your goal is. However, it seems like you are creating a tool that increases player’s speed when equipped and reduces it back to normal when unequipped.
You could use Humanoid.Running event, although I rather suggest listening for .Equipped and .Unequipped events, thus activating the script accordingly. I also can’t know how your current script works. If you are listening for Humanoid.Running event, you first have to know whether tool was equipped or not. Does you tool have a handle? If it doesn’t, precondition is to uncheck RequiresHandle box under properties. We do it all in the following script, which doesn’t include Humanoid.Running.
local player = game:GetService("Players").LocalPlayer
if (not player.Character) then player.CharacterAdded:Wait(); end
local humanoid = player.Character:WaitForChild("Humanoid")
local tool = script.Parent
local defaultSpeed = humanoid.WalkSpeed
-- Every tool requires handle by default.
tool.RequiresHandle = tool:FindFirstChild("Handle") or false
-- Reduce the mass of all parts to zero (not always necessary).
for i, v in pairs(tool:GetDescendants()) do
if (v:IsA("BasePart")) then v.Massless = true end
end
tool.Equipped:Connect(function()
humanoid.WalkSpeed = 30
end)
tool.Unequipped:Connect(function()
humanoid.WalkSpeed = defaultSpeed
end)
What about Humanoid.Running?
tool.Equipped:Connect(function()
-- humanoid.Running event is unnecessary and wastes memory.
connection = humanoid.Running:Connect(function(speed)
humanoid.WalkSpeed = 30
end)
end)
tool.Unequipped:Connect(function()
connection:Disconnect()
humanoid.WalkSpeed = defaultSpeed
end)
EDIT @mikeyaboii3 When a character is standing still, Humanoid.Running generally isn’t present. Humanoid is in state of running without physics applied for most of the time, and switches to running state only the second character starts to move or somehow bounces, after it falls on the ground etc.
Without the script you are using, it’s hard for me or anyone else here to know what could be causing your humanoid to auto-trigger running. Could it be an animation that fires and moves the character? Could it be your tool deliberately moving it? Could it be the model inside the tool, welded and with parts of certain mass, so that moves the character slightly each time the tool is equipped?
Why do you need Humanoid.Running? Do you need to use it? Perhaps you can think of some alternatives. Detecting movement? Maybe magnitude checks are a feasible option.
Hey! Thank you so much for the reply! I’m sorry for not clarifying my question. The problem I was having was, whenever I equip a tool, without even moving, the humanoid.Running runs. And I wanted to know why that was happening and what I could do to avoid it.