I’ve been trying alot of ways to do this but I simply cannot do it. The accessory is created from a model and I don’t want to make it a tool. The problem is that the some parts stick out when it shouldn’t but you know what’s weird that it works fine on 0% Body Type (in the roblox avatar settings).
Here is the function.
function module:SwordAccessory(player, name, direction, angles, offset)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")
local depthScale = humanoid.BodyDepthScale.Value
local heightScale = humanoid.BodyHeightScale.Value
local widthScale = humanoid.BodyWidthScale.Value
if direction ~= "Left" and direction ~= "Right" then return end
local model = sharedAssets.Swords:FindFirstChild(name)
if not model then return end
local handle = model.PrimaryPart
if not handle then return end
if not angles then angles = CFrame.Angles(0, 0, 0) end
if not offset then offset = Vector3.new() end
local accessory = Instance.new("Accessory")
accessory.Name = model.Name
for _,part in pairs(model:GetDescendants()) do
if part:IsA("BasePart") and handle ~= part then
local clone = part:Clone()
clone.Size = Vector3.new(part.Size.X * widthScale, part.Size.Y * heightScale, part.Size.Z * depthScale)
clone.Parent = accessory
end
end
handle = handle:Clone()
handle.Size = Vector3.new(handle.Size.X * widthScale, handle.Size.Y * heightScale, handle.Size.Z * depthScale)
handle.Name = "Handle"
handle.Parent = accessory
for _,part in pairs(accessory:GetChildren()) do
if part:IsA("BasePart") and handle ~= part then
local weld = Instance.new("WeldConstraint")
weld.Part0 = handle
weld.Part1 = part
weld.Parent = part
end
end
for _,part in pairs(accessory:GetChildren()) do
if part:IsA("BasePart") then
part.CanCollide = false
part.Anchored = false
end
end
local attachment = Instance.new("Attachment", handle)
attachment.Name = direction .. "GripAttachment"
attachment.CFrame = attachment.CFrame * angles + offset
return accessory
end
With 0% Body Type
With 100% Body Type