Here is a script that slowly does damage while the player is in it. Unfortunately it doesn't work all the time. I put it in a block and put the blocks down different places so when the player walks through it it does damage.
~~~~~~~~~~~~~~~~~
local damage = 1 local touched local timebeforeotherdamage = 1
01 | script.Parent.Touched:Connect( function (hit) |
02 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
03 | if touched = = false then |
04 | touched = true |
05 | repeat |
06 | if touched = = true then |
07 | hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage |
08 |
09 | end |
10 | wait(timebeforeotherdamage) |
11 | until |
12 | hit.Parent.Humanoid.Health = = 0 |
13 | end |
14 |
15 | end |
sometimes it will do a little damage, but when you go out of the block and back in, it does A LOT. The code looks fine to me so I don't know whats wrong...
This might work! Put this in a script inside of your damage part. Change the wait(1) to change how many seconds you want to wait in between damaging. Change the hum:TakeDamage(50) to how much damage you want to do. If this doesn't work or gives an error, tell me in the comments of this answer and I'll fix my code.
01 | local part = script.Parent |
02 | local debounce = false |
03 | part.Touched:Connect( function (touched) |
04 | local hum = touched.Parent:FindFirstChild( "Humanoid" ) --if its a player |
05 | if hum then |
06 | if debounce = = false then |
07 | hum:TakeDamage( 50 ) --Damage you want to do |
08 | wait( 0.5 ) --wait whatever amount of seconds |
09 | debounce = true |
10 | end |
11 | end |
12 | end ) |
**EDIT: you can make it the part's transparency 1 and cancollide false to make it sort of an invisible "damage zone"
Make sure it's a server script and inside of your part. Hope this works :)