:Destroy() won't destroy my model, it just moves

Hi, I’ve got a bit of an issue, when my event is fired, if accessory is equal to "TakeOff" then it should delete my accessory. I’ve checked to see if it’s sending the names right and stuff, it all fires and prints it however, it doesn’t delete my model it just comes off my character and goes to a random place (still a child of my character though). It’s really confusing, any help is appreciated.

local ss = game:GetService("ServerStorage")
local folder = repstore:WaitForChild("AvatarEditEvents")
local event = folder:WaitForChild("WeldAccessoriesEvent")

event.OnServerEvent:Connect(function(plr, bodypart, accessory, of)
	local character = plr.Character
	local gear = ss.SanFransiscoPD:WaitForChild(accessory)
	local clone = gear:Clone()
	local weldme = clone:GetChildren()
	clone.PrimaryPart = clone:WaitForChild("Middle")
	clone.Parent = character
	if of == "PutOn" then
		print("add")
		for i, v in pairs(weldme) do
			if v.ClassName == "Part" or v.ClassName == "UnionOperation" or v.ClassName == "WedgePart" or v.ClassName == "MeshPart" then
				local weldtomid = Instance.new("WeldConstraint")
				weldtomid.Name = "AllWeld"
				weldtomid.Parent = clone.Middle
				weldtomid.Part0 = clone:WaitForChild("Middle")
				weldtomid.Part1 = v
				v.Anchored = false
				v.CanCollide = false
			end
				local plrtopart = Instance.new("WeldConstraint")
				plrtopart.Name = "StrongWeldOfHolding"
				plrtopart.Parent = character:WaitForChild(bodypart)
				local weldto = character:WaitForChild(bodypart)
				local orientation = weldto.Orientation
				clone:SetPrimaryPartCFrame(CFrame.new(weldto.Position) * CFrame.Angles(math.rad(orientation.X), math.rad(orientation.Y), math.rad(orientation.Z)))
				plrtopart.Part0 = clone:WaitForChild("Middle")
				plrtopart.Part1 = weldto
			end
	elseif of == "TakeOff" then
		local access = character:WaitForChild(accessory)
		access:Destroy()
		print("Del")
	end
end)

I just noticed in local access = character:WaitForChild(accessory) you don`t have quotation marks for “accessory” and also the classname for Accessory has a capital A so you should do this: local access = character:WaitForChild("Accessory")

accessory is a value from the remote event

You make this script

local model = script.Parent.Parent
local part = script.Parent

 model:FindFirstChild(part):Destroy()
end

and put it in the parts that you want to destroy

Using :WaitForChild isn’t needed here. You should instead use FindFirstChild.

local Accessory = Character:FindFirstChild(accessory.Name) — assuming you passed an instance

if Accessory then
    Accessory:Destroy()
end

You also don’t need to use WaitForChild in server scripts.

The thing is why does it like move instead of destroy?

Can you provide a gif of what is happening?

Yeah, sure. Here it is.

https://gyazo.com/85e1a40c8f291e9a70c36dd4e95e486f

I believe this is your issue. You are creating a new gear when the event fires, not if “of” is equal to true.

Oh yeah, silly me :man_facepalming:

Thanks for the help :smiley: