How can I fix this damage zone?

Still bypass the team thing for some reasons

post new script let me see if the changes are correct again…

Here it is :
I’m doing 4 script at the same times lmao

local allies = {
	["SH"] = true,
	["Pizza"] = true,
	["Obamium"] = true,
	["BigShaq"] = true,
	["IKEA"] = true,
	["SCP-035"] = true,
	["SCP-049"] = true,
	["SCP-076"] = true,
	["SCP-106"] = true,
	["SCP-407"] = true,
	["SCP-457"] = true,
	["SCP-745"] = true
}

local Team = game:GetService("Teams")
local players = game:GetService("Players")
local part = script.Parent.FireDamageZone
local Hits = {}

function GetPlayersInPart(allies) -- list of allies
	local part = script.Parent.FireDamageZone
	local min = Vector3.new(part.Position.X-part.Size.X/2, part.Position.Y-part.Size.Y/2, part.Position.Z-part.Size.Z/2)
	local max= Vector3.new(part.Position.X+part.Size.X/2, part.Position.Y+part.Size.Y/2, part.Position.Z+part.Size.Z/2)
	local region = Region3.new(min, max)
	local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)
	local Players = {}
	for _,Part in pairs(partsInRegion) do
		if Part.Name == "HumanoidRootPart" then
			if allies[Part.Parent.Name] then wait()
			else
				table.insert(Players,Part.Parent)
			end
		end
	end
	return Players
end

game.ReplicatedStorage.MusicSCP.OnServerEvent:Connect(function()
	script.Parent.Head.Music:Resume()
	
	while wait(1) do
		local players = GetPlayersInPart(allies)
		for _,v in pairs(players) do
			v.Humanoid:TakeDamage(20)
		end
	end
end)

game.ReplicatedStorage.MusicSCPStop.OnServerEvent:Connect(function()
	script.Parent.Head.Music:Stop()
end)

sorry for the late reply
can you print allies[Part.Parent.Name] in the function after

It return the same result :
Print : nil (x…) again and agin

Got a question can I see workspace with these NPC’s? Are their Model names in the list

This is the npc :
image

Ok but is his name in the allies list

EDIT: Example

image
is also in the list
image

I didn’t place it in the allies list since I’m trying to check if it correctly damage the other player,


It’s not an NPC name, but a team name

What do you mean by

the function I gave you checks the all parts in a region3 and gives which ones name is in Allies. Im very lost on what your trying to accomplish now.

If you look here this is what im saying the model should be named exactly as its in the list

It’s not individual players, it’s team name, if the player isn’t in the team, we damage him

How does the teams work? You can’t just mix things together hoping they are going to work you must integrate it with your current system

EDIT: Do we have a list of players which are assigned to each team

Well there are teams. At the beginning of the game, players are split up in the teams. And the problem is that if I name EVERY possible username ever, it will never work. So i’m trying to make a function which check if the player is on the “Allies” team.

Yes allies are the NPC’s/Players correct?

Allies are the name of the teams :,)

Have you tried using ForeverHD’s Zone+ v2 module? It’s quite easy to use for this type of project.

Wow dude, too good to be true
Thanks for this link

1 Like

Looks a bit difficult, I’m just a begginner you know ^^’

Welp, another problem I’ll have to fix, thanks for your help guys