I am trying to make a part where you stand on the part and whilst standing on it you will take damage the remainder of the time you are standing on it. Once the player comes off the part the damage is stopped. Here's the code;
-- When player touches part and it is true, health decreases by 10
local decrease = script.Parent
local HEALTH = 100
local function onTouch(plr)
print("Ouch")
local player = plr.Parent
local character = player:FindFirstChildWhichIsA("Humanoid")
if character then
character.Health = HEALTH - 10
end
end
decrease.Touched:Connect(onTouch)
This would help me figure out if someone could answer!

2 comments
I still haven't learned Arrays nor Tables so this very much confuses me including the i,v pairs part especially but I am using roblox devhub so slowly figuring out but thank you!
i,v pairs is used to loop through the elements of an array, the i represents the index of the current element, and v represents the value of the element, you can get a better understanding when you print i and v and watch the output. arrays are just a collection of instances, the instances in this case being the players and player parts. You can read more about this online, happy learning!