So i had been using this script for awhile, but it became very slow to use. and boring.
So this script its proposit, its Deleting a tool when player is on a certain team. But after a while of using it, i would want if its possible to put more than 1 tool instead or multiple teams, because i have doing it for a while and i have many script regarding the same stuff, for example.
Team1 has tool removed “ak-47” and “m9”, and adding new stuff has been a little deprecated. Because my game has like 5 Teams each, and i keep adding the tools to be deleted, sorry if not clear. english is not my main language. Heres is the script.
In short, A way this could be improved in a way that deletes many tools on a certain team if possible or even delete many tools on more than 1 team.
local Team = game:GetService("Teams")["Ciudadanos"]
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player.Team == Team then wait(0.5)
if Character:FindFirstChild("Tool") then
Character:FindFirstChild("Tool"):Destroy()
elseif Player.Backpack:FindFirstChild("Tool") then
Player.Backpack:FindFirstChild("Tool"):Destroy()
end
end
Player.Team.Changed:Connect(function()
if Player.Team == Team then wait(0.5)
if Character:FindFirstChild("Tool") then
Character:FindFirstChild("Tool"):Destroy()
elseif Player.Backpack:FindFirstChild("Tool") then
Player.Backpack:FindFirstChild("Tool"):Destroy()
end
end
end)
end)
end)
Well you could possibly as a starter make the Tool change into, something like →
local Tool1 = "Sword"
local Tool2 = "Bat"
local Tool3 = "Katana"
Then for the parts like -
if Player.Team == Team then wait(0.5)
if Character:FindFirstChild("Tool") then
Character:FindFirstChild("Tool"):Destroy()
elseif Player.Backpack:FindFirstChild("Tool") then
Player.Backpack:FindFirstChild("Tool"):Destroy()
end
end
You could change it to -
if Player.Team == Team then wait(0.5)
if Character:FindFirstChild(Tool1,Tool2,Tool3) then
Character:FindFirstChild(Tool1,Tool2,Tool3):Destroy()
elseif Player.Backpack:FindFirstChild(Tool1,Tool2,Tool3) then
Player.Backpack:FindFirstChild(Tool1,Tool2,Tool3):Destroy()
end
end
But maybe look at tables and arrays? That could possibly be easier.
local Team = game:GetService("Teams")["Ciudadanos"]
local Players = game:GetService("Players")
local ResistrictedTools = {"Tool1","Tool2"}
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player.Team == Team then
for i,v in pairs(Player.Backpack:GetChildren()) do
if table.find(ResistrictedTools,v.Name) then
v:Destroy()
end
end
end
end)
end)
Multiple tools, thats what i made the post for, i have multiple scripts each one for 1 tool for 1 team, they are like 4 tools to remove on 1 team and i have around 5ish teams.
I hope you remembered to edit the restrictedtools table with the correct tool names.
local Team = game:GetService("Teams")["Ciudadanos"]
local Players = game:GetService("Players")
local Restricted = {"ToolName1","ToolName2"}
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player.Team == Team then
for i,v in pairs(Player.Backpack:GetChildren()) do
if table.find(Restricted,v.Name) then
v:Destroy()
end
end
end
end)
end)
Sorry for late reply, went to sleep and school. The script still seems to not work for me. I might try it on an empty baseplate later. (Nothing on the output)