I've been working on a piggy game, and then my game broke and this error while playing with fan: attempt to index nil with 'Name'? please help me!
Thanks!
function module.DressPiggy(noob) local character if noob.EquippedSkin.Value ~= "" then if game.ReplicatedStorage.Skins:FindFirstChild(noob.EquippedSkin.Value) then character = game.ReplicatedStorage.Skins[noob.EquippedSkin.Value]:Clone() end else character = game.ReplicatedStorage.Skins.Noob:Clone() end character.Name = noob.Name noob.Character = character character.Parent = workspace end
The problem is you have the lines 11-15 outside of the if statement, so "character" is wiped. You can move those lines below character to fix it. Let me know if it fixes it!
Here's the modified code.
function module.DressPiggy(noob) local character if noob.EquippedSkin.Value ~= "" then if game.ReplicatedStorage.Skins:FindFirstChild(noob.EquippedSkin.Value) then character = game.ReplicatedStorage.Skins[noob.EquippedSkin.Value]:Clone() end else character = game.ReplicatedStorage.Skins.Noob:Clone() character.Name = noob.Name noob.Character = character character.Parent = workspace end end