I trying to make a part if there are 3 or more people walk on that. they'll die, but i dont know why is it not working.
local Part = script.Parent Part.Touched:Connect(function(hit) for i,v in pairs(#hit.Parent.Name:GetChildren()) do --- Need fix if i > 3 then print("Zomb") Zomb() else break end end)
You could try this but I don't know if it works because I didn't try it
local part = script.Parent -- The Part local Touching = { } -- Everyone who touches the part part.Touched:Connect(function(hit) -- Fires when someone touches it local char = hit.Parent -- Gets the character if game.Players:GetPlayerFromCharacter(char) then -- Checks to see if it is actually a player table.insert(Touching, game.Players:GetPlayerFromCharacter(char)) -- Adds them to the touching table end if #Touching >= 3 then -- if there is 3 or more people touching for i,v in pairs(Touching) do v.Character.Humanoid.Health = 0 -- kills table.remove(Touching, i) -- removes player from the table end end end) part.TouchEnded:Connect(function(hit) local char = hit.Parent -- Gets the character if game.Players:GetPlayerFromCharacter(char) then -- Checks to see if it is actually a player for i,v in pairs(Touching) do if v.Name == game.Players:GetPlayerFromCharacter(char).Name then -- finds where player is located in the table table.remove(Touching, i) -- removes player from table end end end end)
You can try making a number value and then in your script put:
local part = script.Parent part.Touched:Connect(function(hit) local PlrsTouchingCount = script.Parent.NumberValue --I said NumberValue but make sure to change this into the name of your number value PlrsTouchingCount.Value = PlrsTouchingCount.Value+1 end) --Now we are gonna make it so when they are not touching the part then it doesnt count them in the NumberValue part.TouchEnded:Connect(function(hit) local PlrsTouchingCount = script.Parent.NumberValue --Remember change the word NumberValue into the name of your real NumberValue PlrsTouchingCount.Value = PlrsTouchingCount.Value-1 end)
Hope this helps :D