How to make a certain value go down?

I have this running script:
(Along with some other things in there)

local KeyPressed = script.Parent.KeyPressed
--//Animations/--
local BloodSuck = script.BloodSuck


KeyPressed.OnServerEvent:Connect(function(Player, Key)
	local character = Player.Character or Player.CharacterAdded:Wait()	
	local humanoid = character:FindFirstChild("Humanoid")
	local BloodSuckTrack = humanoid:LoadAnimation(BloodSuck)
	if Key == "G" then
		BloodSuckTrack:Play()
	elseif Key == "LeftShift" then
		if Player:WaitForChild("Classes"):WaitForChild("Vampire").Value == true then
		humanoid.WalkSpeed = 50
		elseif Player:WaitForChild("Classes"):WaitForChild("Human").Value == true then
			humanoid.WalkSpeed = 23
			end	
	elseif Key == "LeftShiftEnded" then
		if Player:WaitForChild("Classes"):WaitForChild("Vampire").Value == true then
			humanoid.WalkSpeed = 30
		elseif Player:WaitForChild("Classes"):WaitForChild("Human").Value == true then
			humanoid.WalkSpeed = 16
		end	
	end
end)

How would I make an intvalue go down while the player is running.

1 Like

Whenever you change Walkspeed:

while humanoid.WalkSpeed == 50 or humanoid.WalkSpeed == 23 do

	wait(1)
	IntValue.Value += 1

end

If they have the walkspeed of a player or vampire running, then increase the IntValue by 1 each second

Good idea, i’ll try it right now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.