game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
local Tools = Character:GetChildren()
if Humanoid then
Humanoid:UnequipTools()
print("...")
end
for i, v in ipairs(Tools) do
if v:IsA("Tool") then
if Humanoid then
v.Equipped:Connect(function()
Humanoid:UnequipTools()
print("Unequip")
end)
end
end
end
end)
end)
“…” is being printed but “Unequip” isn’t. Why??
Also this script is placed inside ServerScriptService if that matters
Help pls
The issue is most likely because you check the character for the tools, which wouldn’t have anything because it has no tools inside of the character. Try checking the player’s backpack instead, where the tools most likely will be. Replace the Character in the quotted code with Player:WaitForChild("Backpack")
I’ve made the changes that you suggested. Though I still don’t know why v isn’t being printed on print(v)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
local Tools = Player:WaitForChild("Backpack")
if Humanoid then
Humanoid:UnequipTools()
print("...")
end
for i, v in ipairs(Tools:GetChildren()) do
print(v)
if v:IsA("Tool") then
print(v.."Tool")
if Humanoid then
v.Equipped:Connect(function()
Humanoid:UnequipTools()
print("Unequip")
end)
end
end
end
end)
end)
As far as I know, .Equipped works only for client-sided script. There are other ways to do check whether the tool’s been equipped since when a tool is equipped it gets parented to the character. You could compare the tools that were initially inside the backpack and the tool that has been added to the character through ChildAdded. Try:
for i, v in ipairs(Tools:GetChildren()) do
if v:IsA("Tool") then
if Humanoid then
Character.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") and tool == v then
Humanoid:UnequipTools()
end
end)
end
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Tools = Player:WaitForChild("Backpack")
local Humanoid = Character:WaitForChild("Humanoid")
for i, v in ipairs(Tools:GetChildren()) do
if v:IsA("Tool") then
if Humanoid then
Character.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") and tool == v then
Humanoid:UnequipTools()
end
end)
end
end
end
end)
end)
I tried yours, it’s not doing anything
I tried something else:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while true do wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Child = Player.Backpack.ChildAdded
if Child then
Humanoid:UnequipTools()
print("Unequip")
end
end
end)
end)
There are 2 different scripts that clones some tools from the replicated storage and parents them into the players character. That’s why I thought I needed a while loop to unequip them
Why would you need a while loop to unequip them? As for the tool replication, it’s as simple as just parenting the tools to the player’s backpack once they have joined the game.