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)