I have tried using RenderStepped but that still runs when the player is standing still
local RunService= game:GetService("RunService")
local Num = 0
RunService.RenderStepped:Connect(function()
Num = Num+1
print(Num)
end)
I have tried using RenderStepped but that still runs when the player is standing still
local RunService= game:GetService("RunService")
local Num = 0
RunService.RenderStepped:Connect(function()
Num = Num+1
print(Num)
end)
humanoid has a function called running:
local running = false
game.Workspace.Player.Humanoid.Running:Connect(function(speed) -- define humanoid
if speed > 0 then
running = true
-- code here(but make sure to constantly whether the player is running via the variable)
else
running = false
end
end)
for ur instance since ur function is already a loop u can do this:
local running = false
local Num = 0
game.Workspace.Player.Humanoid.Running:Connect(function(speed)
if speed > 0 then
running = true
else
running = false
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if running then
Num = Num + 1
print(Num)
end
end)
PS: im not merging the speed function with the renderStepped such that u can use it to check other things but u could also just combine it to loop check the humanoid speed
In that case can't a state identifier work for ex. Humanoid.HumanoidStateType ...
Thank you it worked perfectly fine!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
UserInputService? ContextAction works too