So basically, i'm trying to count the total walking time a player has made and print it, but it just prints 0 or numbers that have nothing to do with the total walking time.
The script is a LocalScript parented to a NumberValue, which value is supposed to be the total walking time.
local StateType = Enum.HumanoidStateType
local agility = script.Parent.Value
local plr = game.Players.LocalPlayer
local agilitygain = 0
local function AddAgility()
if plr.Character.Humanoid:GetState() == StateType.Running then
while wait(0.1) do
if plr.Character.Humanoid.MoveDirection.Magnitude > 0 then
agilitygain +=0.1
else
agility = agility+agilitygain
print("AgilityGain is:",agilitygain)
print("Agility is:",agility)
agilitygain = 0
agility = script.Parent.Value
break
end
end
end
end
plr.Character:WaitForChild("Humanoid").Running:Connect(AddAgility)
Any help would be appreciated :)
