I am fairly new to this but I am trying to disable my function if a player is on a certain team but just for that team. Say a person was on the grey I am removing all clothes except for that team. This is my script so far:
local Players = game:GetService("Players")
-- For Cleaning One Player:
local function CleanPlayer(Player, NotColor)
if Player ~= NotColor then return end
local Character = Player.Character
for _, CharacterInstance in ipairs(Character:GetChildren()) do
if CharacterInstance:IsA("Shirt") or CharacterInstance:IsA("Pants") then
CharacterInstance:Destroy()
end
end
end
-- If You Want To Clear All Players In One Go:
local function CleanPlayers(NotColor)
for _, Player in ipairs(Players:GetPlayers()) do
CleanPlayer(NotColor)
end
end
-- Something Like You Made:
local NotColor = "Medium Stone Grey"
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Chatacter)
CleanPlayer(NotColor)
end)
end)
local function foo(bar)
print(bar)
end
--use the function
foo("hello world")
--disable the function
foo = function()end
--try to use the function again
foo("hello world")
This is probably what you don’t want to do, but again, this is my understanding of “disabling a function”.
local Players = game:GetService("Players")
-- For Cleaning One Player:
local function CleanPlayer(Player, NotColor)
if Player.TeamColor ~= NotColor then return end
local Character = Player.Character
if Character == nil then return end
for _, CharacterInstance in ipairs(Character:GetChildren()) do
if CharacterInstance:IsA("Shirt") or CharacterInstance:IsA("Pants") then
CharacterInstance:Destroy()
end
end
end
-- If You Want To Clear All Players In One Go:
local function CleanPlayers(NotColor)
for _, Player in ipairs(Players:GetPlayers()) do
CleanPlayer(Player, NotColor)
end
end
-- Something Like You Made:
local NotColor = "Medium Stone Grey"
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Chatacter)
CleanPlayer(Player, NotColor)
end)
end)