The script works but when you look at it, its uhhh…
function Weld:CleanUp(player)
local character = player.Character
local holsterClone = character.Holster:GetChildren()
for i, v in pairs(holsterClone) do
v:Destroy()
end
local primaryClone = character.Primary:GetChildren()
for i, v in pairs(primaryClone) do
v:Destroy()
end
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") and v.Name == "MainHandle" then
v:Destroy()
end
end
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Weld") and v.Name == "MainHandle" then
v:Destroy()
end
end
print("worked")
end
Basically destroys the children of primary and holster folders
function Weld:CleanUp(player)
local character = player.Character or player.CharacterAdded:Wait()
character.Holster:ClearAllChildren()
character.Primary:ClearAllChildren()
for _, Child in pairs(character:GetDescendants()) do
if (Child:IsA("Motor6D") or Child:IsA("Weld")) and Child.Name == "MainHandle" then
Child:Destroy()
end
end
print("worked")
end
try out this code, tell me if you got any problems
Here yuh go, I fixed it since someone was getting mad
function Weld:CleanUp(player) --// Your function
local character = player.Character
local success, errorMessage = pcall(function() --// Incase a error code doesent STOP
character.Holster:ClearAllChildren() --// Clears EVERYTHING in it
character.Primary:ClearAllChildren() --// Clears EVERYTHING in it
for _, object in ipairs(character:GetDescendants()) do --// Gets EVERYTHING in player character
if (object:IsA("Weld") or object:IsA("Motor6D")) and object.Name == "MainHandle" then --// Check if its the thing your looking for
object:Destroy() --// Deletes weld
end
end
end)
if success then --// If there were no problems deleting the welds and motor6Ds
print("Worked!")
else --// If there was a problem
print("Something Went Wrong!")
warn(errorMessage)
end
end
FYI both Motor6D and Weld inherit from JointInstance, so instead of a line of IsA checks just do one on JointInstance. Motor6D and Weld IsA JointInstance therefore is a candidate for deletion.
Here’s one you can use:
function Weld:CleanUp(player)
local character = player.Character
if not character then return end
for _, child in ipairs(character:GetChildren()) do
if child:IsA("Model") and (child.Name == "Holster" or child.Name == "Primary") then
child:ClearAllChildren()
elseif child:IsA("JointInstance") and child.Name == "MainHandle" then
child:Destroy()
end
end
end