How would I SLOWLY decrease all players health?
I know I would use
i,v in pairs do()
and change all humanoids
.Health
value. But I don't know how to go about that.
As you knew, iterate through each player in the game via the :GetPlayers() function of Players.
Allocate their Characters' Humanoid
Instance, then begin decreasing their health through a loop.
pairs
iterator from continuing forward with initiating the other Player's health decrement.local Players = game:GetService("Players") for _, Player in pairs(Players:GetPlayers()) do local Character = Player.Character if (Character) then --------------- local Humanoid = Character.Humanoid --------------- spawn(function() --------------- while (Humanoid.Health > 0) do Humanoid.Health -= 1 --------------- wait(--[[Time]]) end end) end end
Hey! I can't write scripts for you but, I reccomend looking at https://developer.roblox.com/en-us/api-reference/property/Humanoid/Health and https://blog.roblox.com/2012/05/using-wait-wisely/
Use a for loop and loop through the array of players using :GetPlayers()
. Keep in mind you must use a different thread for each player, which can be done using spawn
, coroutine.wrap
, or coroutine.resume(coroutine.create())
.
for _, player in ipairs(game:GetService("Players"):GetPlayers()) do local character = player.Character if not character then continue end local humanoid = character.Humanoid coroutine.wrap(function() while humanoid and humanoid.Health > 0 do humanoid.Health -= 1 wait(n) end end)() end