I don’t think it could help us very much, since if he can’t destroy a model he’s probably setting the wrong path to destroy it
Ok here is my entire script.
local module = {}
function module.DropTools(plr,map,position)
-- look for tools in the players Backpack
for i, tool in pairs(plr.Backpack:GetChildren()) do
if tool:IsA("Tool") and game.ServerStorage.KeyHandles:FindFirstChild(tool.Name) then
local clone = game.ServerStorage.KeyHandles:FindFirstChild(tool.Name):Clone()
if clone:IsA("Model") then
clone:SetPrimaryPartCFrame(CFrame.new(position))
else
clone.Position = position
end
clone.Parent = map.Items
tool:Destroy()
end
end
-- look for tools in your Character
for i, tool in pairs(plr.Character:GetChildren()) do
if tool:IsA("Tool") and game.ServerStorage.KeyHandles:FindFirstChild(tool.Name) then
local clone = game.ServerStorage.KeyHandles:FindFirstChild(tool.Name):Clone()
if clone:IsA("Model") then
clone:SetPrimaryPartCFrame(CFrame.new(position))
else
clone.Position = position
end
clone.Parent = map.Items
tool:Destroy()
end
end
end
function module.Clicked(plr,item)
if plr then
if plr.Character and not plr:FindFirstChild("Contestant") then
local position
if item:IsA("Model") then
position = item.PrimaryPart.Position
else
position = item.Position
end
module.DropTools(plr,game.Workspace.map,position)
print("Dropped Keyhandles")
if game.ServerStorage.Tools:FindFirstChild(item.Name) then
local clonedTool = game.ServerStorage.Tools[item.Name]:Clone()
clonedTool.Parent = plr.Backpack
plr.Character.Humanoid:EquipTool(clonedTool)
repeat
item:Destroy()
until item == nil
print("Equipped The tool object")
end
end
end
end
return module
Show us the script that uses module.Clicked
And also, it would be easier if you uploaded your scripts to pastebin, so we can actually see the line numbers. or, use screenshots.
You’re avoiding a bigger problem here, but I guess you don’t mind. ¯_(ツ)_/¯
Ok ran your code and it also worked but with no lag.
Oh I removed it because I thought it wouldn’t work. Interesting
Sorry if I ask, but can you set the answer to the answer? Because what you checked as answer is just a statement telling you to show the script. I say that because other people might find it hard to find the answer
Yeah that is interesting. (30 characters)
Oh yeah I just changed that I had no idea.
Here is my solution he switched to, apparently without lag:
repeat wait() until item ~= nil;
item:Destroy()
How do you even know that the object still exists after you’ve called Destroy? Surely you must have some kind of debug hanging around. Destroy will destroy an object: if you’re still seeing it around such as printing out the contents of a table, then you have a memory leak. You need to lose all references to a destroyed object so it can be garbage collected.