Here is the script:
game.Workspace.Part.Touched:Connect(function(hit) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Humanoid.Health = 0 end end)
When the game starts up it just kills you, but after that it's fine. Does anyone have a solution?
i'm a little confused by the question. you say it works fine, however, in the title, it says it doesn't work...?
well, either way, the reason it kills you right away is because the touched event fires the moment the part touches something. you don't have it detect the humanoid of the player(s) who touched it.
here's an example of how you'd go about this:
game.Workspace.Part.Touched:Connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h then for i, player in ipairs(game.Players:GetChildren()) do player.Character.Humanoid.Health = 0 end end end)
Its becaused the script target a single player, you need to change it so it will target every player in the local function