I’ve been running into an issue that I couldn’t find a solution for. I’ve been running into a bug where, whenever I equip a tool and unequip it then reequip it, it randomly will unequip and drop the tool.
I have CanDrop
on the tools off and have it set RequireHandle
to true. I’m unsure on how to fix this bug and I was hoping someone could help out.
Here’s the code that manages the tools, the script is in ServerScriptService
local RS = game:GetService("ReplicatedStorage")
local DropEvent = RS.Events.DropPart
local ThrowEvent = RS.Events.ThrowPart --This is irrelevant
local EquipEvent = RS.Events.EquipTool
local UnequipEvent = RS.Events.UnequipTool
DropEvent.OnServerEvent:Connect(function(player, Tool)
local Char = player.Character
local ClonePart = RS.Parts:FindFirstChild(Tool.Name):Clone()
ClonePart.Size = Vector3.new(1,1,1) * Tool.Size.Value
ClonePart.Parent = workspace.Parts
ClonePart.CFrame = Char.Head.CFrame * CFrame.new(0, 0, -2)
Tool:Destroy()
end)
EquipEvent.OnServerEvent:Connect(function(player, Tool)
local hum = player.Character.Humanoid
hum:EquipTool(Tool)
end)
UnequipEvent.OnServerEvent:Connect(function(player)
local hum = player.Character.Humanoid
hum:UnequipTools()
end)