Hello there.
While making an Accessory System similar to Royale High one, I encountered an issue that I never faced before: Motor6D and Weld Constraint are not able to overwrite the Part1 property(not because the part1 doesn’t exist).
This is the code that a week ago worked but now it suddenly doesn’t:
function AccessoryService:CreateWeld(parent, part0, part1)
local weld = Instance.new("WeldConstraint")
weld.Part0 = part0
weld.Part1 = part1
weld.Parent = parent
end
function AccessoryService:Create6D(parent,part0, part1)
local motor6D = Instance.new("Motor6D")
motor6D.Part0 = part0
motor6D.Part1 = part1
motor6D.Parent = parent
end
function AccessoryService:Weld(parent, part0, part1)
self:CreateWeld(parent, part0, part1)
self:Create6D(parent, part0, part1)
end
function AccessoryService:PreFabAccessory(plr: Player, accessoryProfile)
if not accessoryProfile then warn(string.format(ACCESSORY_PROFILE_NIL, accessoryProfile.Attributes.AccessoryId or "*not specified*")) return end
local char = plr.Character
local accClone = accessoryProfile.Instance:Clone()
local primaryPart = accClone.PrimaryPart
local attachType = accessoryProfile.Attributes.AttachType
local partToAttachTo = char:FindFirstChild(accessoryProfile.Attributes.PartToAttachTo)
if attachType then
--Applicate specific attachment type
print(attachType)
else
accClone:PivotTo(partToAttachTo.CFrame)
self:Weld(primaryPart, primaryPart, partToAttachTo)
end
accClone.Parent = char
print("Pre-fab Stage")
return accClone
end