Enemies and Allies can kill Its door

local Time = 1.5 
local Damage = 100 
debounce = true

script.Parent.Touched:connect(function(hit)
	if (debounce == true) then
		debounce = false
		local a = game.Players:GetChildren()
		for i = 1, #a do
			if a[i].Name == hit.Parent.Name then
				local b = hit.Parent:FindFirstChild("Humanoid")
				if not b then return end
				if b.MaxHealth >= 100 then
					b.Health = 0
				else
					b.Health = b.Health - Damage 
				end
			end
		end
		wait(Time) 
		debounce = true
	end
end)

here is my friend helped and gave me this script

Sadly it does not detect teams, can you ask him to use the methods I showed to make it detect teams.

When zombies are bots in my game and you have some problem with your own game

Although you know in my game Re-make there is a script that checks the commands, but it does not kill, I just do not miss it You are a programmer, you better know

Door = script.Parent 
modelname="Red" 

 function onTouched(hit) 
        local human = hit.Parent:FindFirstChild("Humanoid") 
        if (human ~= nil ) then
                if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
                       -- Door.CanCollide = false 
                        --Door.Transparency = 1
                        --wait(0.3) 
                        --Door.CanCollide = true  -- edit here
                       -- Door.Transparency = 1 
                else
                        human.Health = 0
                end
 
        end 
end 
 
connection = Door.Touched:connect(onTouched)

This Script not my This was done by my friend

Shouldn’t you ask your friend for help first then? Doesn’t make much sense to ask about code that you yourself don’t first understand, let alone code you didn’t write. It makes explaining significantly more difficult and especially moreso when not enough information or applicability of presented concepts is happening.

Remember to check the Developer Hub if you’re interested in getting a start on Roblox programming.

Well, I know that I need to do it myself, but my friend is the one who teaches me in the Lua language.

Then you should probably ask him about the script.

Considering what it was supposed to do, I don’t see an issue with the given code.

In general, the script was designed to open doors
But now you can change it. Well, I can say that he checks the team of the player, can kill the player, if he does not belong to the team that was written in the script, the script works on my map, how to skip the spawn