i was trying to make an attack by spawning a part with a script in front of a player and it worked if i just put the part in workspace, but if i clone the script into a part, it doesnt work anymore for some reason.

script.Parent.Touched:connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid")~= nil then

hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25

script.Parent:remove()

end

end)

this is the script I used. I checked, and the script was cloned into the part, it had the right text in it and it wasnt disabled. does anyone know why this happens?