I'm not sure why you'd want a part to kill when it enters the workspace, but it is a little more complicated than that.
First, you need to have an event listener which waits for the part to enter the workspace. You can use ancestrychanged for this:
https://developer.roblox.com/en-us/api-reference/event/Instance/AncestryChanged
Second, :GetChildren() is a function that returns an array of all chidren to the instance it was called on. It cannot scan for specific types, nor does it return anything more than immediate children. As a result, calling :GetChildren() on game returns high level services like the workspace and serverscriptservice.
To amend this issue, you need to find all players first. You can do this easily by doing game.Players:GetChildren(), which returns all of the children to the Players service. This is not enough however, because you need to set all of their character humanoids health to 0. That is when a loop comes in.
To iterate over an array, you can use a for loop like this:
for i,v in pairs (array) do
end
i will represent the index (or number) in the array, while v is the entry in the array itself.
Using a for loop over all players, you can set v.Character.Humanoid.Health=0.
If you need more help, let me know.
3 comments
hi
hi
hi