I’m helping a game where you collect cups and when you drink the cups your rig changes to a different rig, and that gives you abilities and powers. However, for my module script to make the player turn into the rig, its not working. When I joined the game it was just my normal Roblox character. The trolls can have varied faces, extra meshes, colors, etc. Here are examples of the rigs:
I achieved that by changing the StarterCharacter (now startercharacter is removed) but that would make everyone’s startercharacter that. I tried using :GetHumanoidDescription() and that still didnt work. No errors were printed.
Module code:
local dress_module = {}
function dress_module:dress(character, shirt, pant, weld_1, weld_2, weld_3, weld_part_1, weld_part_2, weld_part_3, tool_1, tool_2, tool_3, tool_4,tool_5, tool_6, color, face)
local player = game.Players:GetPlayerFromCharacter(character)
--shirts/pants
if (character:FindFirstChildOfClass("Shirt")) then
character:FindFirstChildOfClass("Shirt"):Destroy()
end;
if (character:FindFirstChildOfClass("Pants")) then
character:FindFirstChildOfClass("Pants"):Destroy()
end;
if (shirt) then
shirt:Clone().Parent = character;
end
if (pant) then
pant:Clone().Parent = character;
end
--welds
if (weld_1) then
weld_1.Parent = weld_part_1
local w = Instance.new("WeldConstraint")
w.Parent = weld_1
w.Part0 = weld_1
w.Part1 = weld_part_1
end;
if (weld_2) then
weld_2.Parent = weld_part_2
local w = Instance.new("WeldConstraint")
w.Parent = weld_2
w.Part0 = weld_2
w.Part1 = weld_part_2
end;
if (weld_3) then
weld_3.Parent = weld_part_3
local w = Instance.new("WeldConstraint")
w.Parent = weld_3
w.Part0 = weld_3
w.Part1 = weld_part_3
end;
--tools
if (tool_1) then
tool_1:Clone().Parent = player.Backpack
end;
if (tool_2) then
tool_2:Clone().Parent = player.Backpack
end;
if (tool_3) then
tool_3:Clone().Parent = player.Backpack
end;
if (tool_4) then
tool_4:Clone().Parent = player.Backpack
end;
if (tool_5) then
tool_5:Clone().Parent = player.Backpack
end;
if (tool_6) then
tool_6:Clone().Parent = player.Backpack
end;
--body colors
if (character:FindFirstChildOfClass("BodyColors")) then
character:FindFirstChildOfClass("BodyColors"):Destroy()
end;
color:Clone().Parent = character;
--decals
if (character:FindFirstChildOfClass("Decal")) then
character:FindFirstChildOfClass("Decal"):Destroy()
end;
face:Clone().Parent = character.Head
end
return dress_module
call module code:
local module = require(script.Parent.MODULES.DRESS)
local basic = game.ReplicatedStorage.Trolls.Troll
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
module:dress(character, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, basic:WaitForChild("Body Colors"), basic:WaitForChild("Head").Part)
end)
Is there a different way I could achieve this changing of the rig/changing characters appearance to match the rig? Is there any mistakes in the modules?