I used this script to make the player damage.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(5) wait(1) end end)
But I don't know how to make the player take damage every 1 second he is inside of the part.
Make a script inside of the part:
local damage_delay = 1 local damage = 5 local part = script.Parent local region = Region3.new(part.Position - (0.5 * part.Size), part.Position + (0.5 * part.Size)) while wait(damage_delay) do for _, part in pairs(workspace:FindPartsInRegion3(region, nil, math.huge)) do if part.Name == "HumanoidRootPart" then local human = part.Parent:FindFirstChild"Humanoid" if human ~= nil then human.Health = human.Health - damage end end end end
What this does is creates a region that has the same size as the part and every time there is part inside of it, it checks if part is called humanoid root part and then it damages the player, damage delay is how fast it damages and damage is damage. Hope this helps.
Also you CAN use while loop but i do not recommend it as it may create a mess and damage you very very fast because you can touch the part again while inside of it and that will start the loop again.
so what you would have to do is use a while loop like this
script.Parent.Touched:Connect(function(hit) while true do hit.Parent.Humanoid:TakeDamage(5) wait(1) end end)