-
What do you want to achieve?
I have some kind of outfit equipper, when I press a button a rig model should be copied over from a viewportframe to another, but when it does so it gives me errors in the “Animate” script of the model -
What is the issue?
I tried checking if the “Humanoid” actually exists in the model, and it does, but it still indexes with nil. -
What solutions have you tried so far?
local function findInstance(WorldModel)
for _, name in pairs(OutfitTypes) do
local instance = ffc(WorldModel,name)
if instance then
return instance
end
end
return nil
end
local function PreviewButton()
for _,Frame in pairs(ClothingFrames) do
for i,Container in pairs(Frame:GetChildren()) do
if Container and Container.Name=="Container" then
local ShowButton=Container.ShowButton
ShowButton.MouseButton1Down:Connect(function()
local WorldModel =Container.ViewportFrame.WorldModel
local Rig =findInstance(WorldModel)
for i,v in pairs(ShowCaseFrame.WorldModel:GetChildren()) do
if i>0 then
v:Destroy()
end
end
local outfitName = if Rig:GetAttribute("Outfit_Name")==nil then "Outfit" else Rig:GetAttribute("Outfit_Name")
Left.TextLabel.Text = outfitName
local Clone =Rig:Clone()
Clone.HumanoidRootPart.CanCollide=false
Clone.Parent =ShowCaseFrame.WorldModel
end)
end
end
end
end
If needed, I can provide the function that copies over the models to the viewportframe at the beginning also (this isn’t giving errors, at least I think so)