local redpart = script.Parent
local Player = game.Players.LocalPlayer
local character = Player:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChild("Humanoid")
redpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
while humanoid.Health > 0 do
wait(0.2)
humanoid:TakeDamage(10)
end
end
end)
Ive tried doing this in global and local scripts but Player.Character kept erroring for me on global so just did local (my script isnt working on either though)

2 comments
Thank you for your awnser but also would you happen to know how to stop the damage when TouchEnded tried doing this but wasnt working
I mean you could try to make a new bool value in the part and call it lets say 'Touched'. In the while loop you could say: while hit.parent.Humanoid.Health >0 and redpart.Touched.Value == false do. Another script could change the bool value in the touch ended function.