So basically I’m making a drowning script, but it just won’t work. No errors, just nothing happening.
game.Players.PlayerAdded:Connect(function(player)
DrowningStats = Instance.new("IntValue")
DrowningStats.Name = "DrowningStats"
DrowningStats.Parent = player
end)
local region = Region3.new(Vector3.new(-29.5, 0.5, -45.5), Vector3.new(-79.625, 6.375, -87.5))
local RePart = Instance.new("Part")
RePart.Size = region.Size
RePart.Transparency = 0.5 --this part didnt work
RePart.CanCollide = false
while true do
wait(1)
local partsInRegion = workspace:FindPartsInRegion3(region, RePart, math.huge)
for i, RePart in pairs(partsInRegion) do
if RePart.Parent:FindFirstChild("Humanoid") then -- this part didnt work
char = RePart.Player.Name
DrowningStats.Value = DrowningStats.Value + 1
else
DrowningStats.Value = 0
end
end
end
while true do
wait(1)
if DrowningStats.Value == 15 then
char.Humanoid:TakeDamage(15) -- This part didn't work.
else
print("User still has air")
end
end