while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
for i, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local char = part.Parent
char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
end
end
end
im using a different way to create a variable for the character as im working with region3, however i cant use CharacterAdded:Wait() so i was wondering how do i make this script work again if a player resets?
local playerService = game:GetService("Players")
local part = script.Parent
local pos1 = part.Position - (part.Size / 2)
local pos2 = part.Position + (part.Size / 2)
local region = Region3.new(pos1, pos2)
while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
for i, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local char = part.Parent
local playerFromCharacter = playerService:GetPlayerFromCharacter(char)
local char = playerFromCharacter.Character or playerFromCharacter.CharacterAdded:Wait()
char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
end
end
end