I make guns on roblox whenever I feel like it. I decided to try to add something to them. A walking animation. I checked Venvious' Avert the Odds II game and I couldn't find anything that showed when the player is walking or not. But it still has a walking animation! I looked to see how to check if a player is walking and found you do this:
Player.Character.Humanoid.Running:connect(function(speed) print("Speed: "..speed) end)
So I tried that. But I found myself stuck. I needed to find out how to check if a player has STOPPED walking! I would look at TurboFusion's gun scripts, but within the first 25 lines I get confused. How can you check if a player has stopped walking?
To check if the player is walking or not, we need to see what speed its. An int value so basicly a number. When a player stops walking it returns 0. If it's higher than 0 then they're walking,
Player.Character.Humanoid.Running:connect(function(speed) --I hope player is a variable of an actual player. if speed == 0 then --If they are not walking, print(Player.Name.." has stopped walking.") elseif speed > 0 then --If they started walking or is walking. print(Player.Name.." is walking.") end end)
I hope this helps.
You could also use the Velocity
property.
local Torso = ??? Torso.Changed:connect(function(val) if val == "Velocity" then print("Speed changed: "..Torso.Velocity) end end)