When I press a button on my GUI, I randomly get errors
Workspace.gunsgamertv.Animate:4: attempt to index nil with 'WaitForChild'
But I don’t see anything that like interferes with the script, nor with my character
local function PreviewButton()
for i,Container in pairs(OutfitsFrame: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 = Rig and Rig:GetAttribute("Outfit_Name") or "Outfit"
Left.TextLabel.Text = outfitName
local Clone =Rig:Clone()
Clone.HumanoidRootPart.CanCollide=false
Clone.Parent =ShowCaseFrame.WorldModel
end)
end
end
end
That’s the 3 & 4rd. line of the animate script:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")