local rp = game.ReplicatedStorage
local remotes = rp.Remotes
local virusremote = remotes.Virus
function damageovertimefunc(Humanoid,Dmg,Time,STEP)
--Step = 0.15
local t = 0
repeat wait(STEP)
t = t + STEP
local currentDamage = Dmg/(time/STEP)
Humanoid:TakeDamage(currentDamage) -- ?
until Humanoid == nil or Humanoid.Parent == nil or t >= Time
end
virusremote.OnServerEvent:Connect(function(Player)
print(Player)
local Character = Player.Character
print(Character)
local humanoid = Character:WaitForChild("Humanoid")
local length = 4;
local damagepertimestep = 4;
local timestep = 0.5;
--[[local function doDamageThings()
print("gg gamer")
for _ = 1, length, timestep do
humanoid:TakeDamage(damagepertimestep);
wait(timestep);
end
end]]--
damageovertimefunc(humanoid,4,4,0.5)
--Character.Infected = false
end)
uhm well, this damage overtime is used for a variety of moves in my game, and i want to make it do damage overtime after the onserverevent has been triggered for a time, damage, timestep, and humanoid that i can set (not really required but i like having customizability)… so this wouldnt really help
local damagePerSecond = 15
function damageovertimefunc(Humanoid, Dmg, Time, STEP)
local tPass = 1
while(Humanoid.Health > 0 and tPass <= Time)do
Humanoid:TakeDamage(Dmg)
tPass = tPass + 1
wait(STEP)
end
end
-- Function damages Humanoid with Dmg per STEP seconds until Time seconds have passed (or Humanoid's health is at 0)
game.Players.PlayerAdded:Connect(function (player)
player.CharacterAdded:Connect(function (character)
damageovertimefunc(character.Humanoid, 4, 4, 0.5
end)
end)
well once again it should call the damage over time when a remote event gets a .OnServerEvent… thank you for your contributing though; i don’t need you to do everything for me ik how to program but idk what the issue with my code was…