Errors from Animation Script even if untouched?


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")

Where is your script located? StarterCharacterScripts?

If it’s not in StarterCharacterScripts, it needs to be. Either that, or change your character reference to:

local player = game:GetService(“Players”).LocalPlayer

local Character = player.Character or player.CharacterAdded:Wait()

local Humanoid = Character:WaitForChild(“Humanoid”)

The Animate Script is in starter Character which is always created automatically
image
My other script to handle the GUIs, buttons etc., is in starterplayerscripts

Not sure then. If I were you, I’d still try adding a :Wait(), because it seems like it’s loading the script before the character exists.