Hello, I am having trouble making a kill block that slowly takes away health from a player. I would usually do this with a touched event that gradually takes away damage from the player, but this kill block has no collision and only damages the player when they touch it but stops damaging when they are in it. If you can explain why this is happening and how to fix it, that would be great.
2 Likes
You can use a loop:
while true do
wait(1) -- Change 1 to the ammount of time
script.Parent.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("Humanoid") then
local Human = plr.Parent.Humanoid
Human.Health = Human.Health - 5 -- change 5 to the health you want to lose
end
end)
end
3 Likes
That isn’t the best choice on handling this here
A better solution would be is to use Region3
, which takes an area of the world space & detects it depending on what your Min
& Max
Sizes are
By obtaining the Block’s Size, you can check if a player is inside the Region3
using the workspace:FindPartsInRegion3
function and damage them if they are
The code you’re doing here is creating a Touched
event, which will fire every time the Player touches the event regardless the wait(1)
would do