I am trying to create a class system where a dummy shows how the class looks before the player receives it to do this I was originally using welds on the hat but realized the code was getting unorganized and being an extremely pain to deal with due to the utter size the weld lines had, I tried using a module script to put hats on the dummy locally but that did not work for some reason (I figure it had something to do with getting the dummy model locally)
TLDR: I am wondering if there’s any solutions to creating a module that works locally to equip shirts, pants, and custom hats onto a dummy locally
Below is the model, code sample, and my attempt at a module.
(Before I decided I wanted to use a module:)
local role = Player:GetRoleInGroup(7114124)
local rank = Player:GetRankInGroup(7114124)
if rank > 240 then
local overrank = game.ReplicatedStorage.DeploySystem2.ArmyGroup:FindFirstChild("First Sergeant")
local shirt2 = overrank:WaitForChild("Shirt").ShirtTemplate
game.Workspace.DeploySystem.Dummy.Shirt.ShirtTemplate = shirt2
local pants2 = overrank:WaitForChild("Pants").PantsTemplate
game.Workspace.DeploySystem.Dummy.Shirt.ShirtTemplate = pants2
else
local getrole = game.ReplicatedStorage.DeploySystem2.ArmyGroup:FindFirstChild(role)
local shirt = getrole:WaitForChild("Shirt").ShirtTemplate
game.Workspace.DeploySystem.Dummy.Shirt.ShirtTemplate = shirt
local pants = getrole:WaitForChild("Pants").PantsTemplate
game.Workspace.DeploySystem.Dummy.Pants.PantsTemplate = pants
local hat = getrole:WaitForChild("Hat")
local gear = getrole:WaitForChild("Gear")
local char = game.Workspace.DeploySystem.Dummy
local NewArmor = hat:Clone()
NewArmor:SetPrimaryPartCFrame(char.Head.CFrame)
NewArmor.PrimaryPart:Destroy()
for , part in pairs (NewArmor:GetChildren()) do
if part:IsA("BasePart") then
WeldParts(char.Head, part)
part.CanCollide = false
part.Anchored = false
end
end
NewArmor.Parent = char
local NewArmor1 = gear:Clone()
NewArmor1:SetPrimaryPartCFrame(char.Torso.CFrame)
NewArmor1.PrimaryPart:Destroy()
for , part in pairs (NewArmor1:GetChildren()) do
if part:IsA("BasePart") then
WeldParts(char.Torso, part)
part.CanCollide = false
part.Anchored = false
end
end
NewArmor1.Parent = char
module script attempt:
local TS = game:GetService("TweenService")
local morph = {}
function WeldParts(part0,part1)
local newWeld = Instance.new("Weld")
newWeld.Part0 = part0
newWeld.Part1 = part1
newWeld.C0 = CFrame.new()
newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
newWeld.Parent = part0
end
function morph.Equip(hat,char)
local NewArmor = hat:Clone()
NewArmor:SetPrimaryPartCFrame(char.Head.CFrame)
NewArmor.PrimaryPart:Destroy()
for , part in pairs (NewArmor:GetChildren()) do
if part:IsA("BasePart") then
WeldParts(char.Head, part)
part.CanCollide = false
part.Anchored = false
end
end
NewArmor.Parent = char
end
return morph
hierarchy: