What I want is when a player on a certain team steps on a part, a folder will be destroyed.
Code:
local plr = game.Players:GetPlayerFromCharacter()
script.Parent.Touched:Connect(function(Hit)
if plr.TeamColor == "Really Black" then
workspace["Human safezone"]:Destroy()
end
end)
Give this a try. There are more efficent methods but I did this pretty quickly. Would encourage looking at other replies for more optimal solutions if you get them.
local partToTouch = script.Parent
local function onTouch(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then -- if you have npcs in ur game i'd recommend a diff method of determining if a player touched it.
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.TeamColor.Name == "Really black" then
if workspace:FindFirstChild("Human safezone") then
workspace["Human safezone"]:Destroy()
end
end
end
end
partToTouch.Touched:Connect(onTouch)
script.Parent.Touched:Connect(function(Hit)
local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if not plr then return end
if plr.TeamColor == "Really Black" then
workspace["Human safezone"]:Destroy()
end
end)
script.Parent.Touched:Connect(function(Hit)
local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if not plr then return end
if plr.Team == game:GetService(“Teams”):FindFirstChild(“TeamNameHere”) then
workspace["Human safezone"]:Destroy()
end
end)