Hewo !
I made a script (forget the “fuel” part) that is suppose to take humanoid touching reg3, and then damage him. Problem is that I would like it to damage him every seconds, and if the player die, we add “fuel” to the killer, and add him to the table so he can’t be killed more times. In this script, it damage player instantly a lot of time, until its health = 0. Here is the script :
local fuel = game.ReplicatedStorage.Fuel
local part = script.Parent.FireDamageZone
local isDead = {}
local players = game:GetService("Players")
local fuelLoss
game.ReplicatedStorage.Fuel.Changed:Connect(function()
local min = Vector3.new(part.Position.X-part.Size.X/2, part.Position.Y-part.Size.Y/2, part.Position.Z-part.Size.Z/2)
local Max = Vector3.new(part.Position.X+part.Size.X/2, part.Position.Y+part.Size.Y/2, part.Position.Z+part.Size.Z/2)
local FireReg = Region3.new(min, Max)
if fuel.Value >= 301 then
script.Parent.Humanoid.WalkSpeed = fuel.Value/37.5
script.Parent.LowerTorso.Fire.Size = fuel.Value/100
script.Parent.UpperTorso.PointLight.Range = fuel.Value/30
script.Parent.FireDamageZone.Size = Vector3.new(fuel.Value/60, fuel.Value/60, fuel.Value/60)
for _, part in pairs(game.Workspace:FindPartsInRegion3(FireReg,nil,math.huge)) do
local plr = players:GetPlayerFromCharacter(part.Parent)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum then
hum:TakeDamage(fuel.Value/10)
if hum.Health <= 0 then
if table.find(isDead, plr.Name) then continue end
table.insert(isDead, plr.Name)
fuel.Value = fuel.Value + 75
end
end
end
fuelLoss = 1/(2^(fuel.Value/300)/2)
wait(fuelLoss)
fuel.Value = fuel.Value - 1
else
script.Parent.Humanoid.WalkSpeed = 8
script.Parent.LowerTorso.Fire.Size = 2.5
script.Parent.UpperTorso.PointLight.Range = 15
fuelLoss = 1
wait(fuelLoss)
fuel.Value = fuel.Value - 1
end
end)
wait(1)
fuel.Value = fuel.Value - 1
script.Parent.UpperTorso.FireCrackling:Resume()
-- here, the computer already knows what to do when this value is changed
if fuel.Value == 0 then
script.Parent.Humanoid.Health = 0
script.Parent.UpperTorso.FireCrackling.Looped = false
script.Parent.UpperTorso.FireCrackling:Stop()
end