Hey.
So i was wondering if there was anyway to disable a tools scripts. I couldn’t find a way so I found unequipping the tool from the players backpack and then destroying it was the most efficent. The problem is, even if you are touching the part, the tool gets destroyed for no reason and most of the time the tool does not work.
Here is the script:
local repStorage = game:GetService("ReplicatedStorage")
local tool = repStorage:WaitForChild("GK")
local players = game:GetService("Players")
local part = workspace:WaitForChild("GoaliePartBlues")
local union = workspace:WaitForChild("Union")
local partPlayers = {}
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local player = players:GetPlayerFromCharacter(hit.Parent)
local character = hit.Parent
local humanoid = character:WaitForChild("Humanoid")
if player.TeamColor == BrickColor.new("Bright green") then
if not table.find(partPlayers, player) then
table.insert(partPlayers, player)
local backpack = player:WaitForChild("Backpack")
local tools = character:GetChildren()
if not backpack:FindFirstChild("GK") and not character:FindFirstChild("GK") then
local toolClone = tool:Clone()
toolClone.Parent = player:WaitForChild("Backpack")
for i, tool in pairs(backpack:GetChildren()) do
if tool.Name == "GK" then
humanoid:EquipTool(tool)
end
end
end
end
end
end
end)
part.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local player = players:GetPlayerFromCharacter(hit.Parent)
local character = hit.Parent
if player.TeamColor == BrickColor.new("Bright green") then
for i, v in pairs(partPlayers) do
if v.Name == player.Name then
table.remove(partPlayers, i)
local tools = character:GetChildren()
for i, tool in pairs(player:WaitForChild("Backpack"):GetChildren()) do
if tool.Name == "GK" then
--do nothing for now
end
end
for i, tool in pairs(tools) do
if tool.Name == "GK" then
--do nothing for now
end
end
end
end
end
end
end)
union.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
task.wait(.5)
local player = players:GetPlayerFromCharacter(hit.Parent)
local character = hit.Parent
local humanoid = character:WaitForChild("Humanoid")
local backpack = player:WaitForChild("Backpack")
local tools = character:GetChildren()
for i, tool in pairs(backpack:GetChildren()) do
if tool.Name == "GK" then
task.wait(0.5)
tool:Destroy()
end
end
for i, tool in pairs(tools) do
if tool.Name == "GK" then
task.wait(0.5)
tool:Destroy()
end
end
end
end)
Any help would be appreciated! Thanks.