01 | -------------------------------------------------------------------- |
02 | Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=(ID)" |
03 | ----------------------------------------------------------------------------- |
04 |
05 | Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=(ID)" if Character.Shirt = = nil then |
06 | Instance.new( "Shirt" ).Parent = Character |
07 | wait() |
08 | Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=(ID)" |
09 | end |
10 |
11 | Character [ "Shirt Graphic" ] .Graphic = "http://www.roblox.com/asset/?id=(ID)" if Character [ "Shirt Graphic" ] = = nil then |
12 | Instance.new( "ShirtGraphic" ).Parent = Character |
13 | wait() |
14 | Character [ "Shirt Graphic" ] .Graphic = "http://www.roblox.com/asset/?id=(ID)" |
15 | end |
When I run this script, and the Shirt Graphic is equal to nil, it doesn't run the command told to if it is nil, in the console it just tells me "Attempt to index nil value"
I did add Template IDs into (ID) sections. Earlier in the script it told the script what Character is equal to
Line 11 tries to set the shirt graphic's graphics and will error if there is no shirt graphic since you can't set the graphics value of nothing.
01 | Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=(ID)" |
02 |
03 | Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=(ID)" if Character.Shirt = = nil then |
04 | Instance.new( "Shirt" ).Parent = Character |
05 | wait() |
06 | Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=(ID)" |
07 | end |
08 |
09 | if Character [ "Shirt Graphic" ] = = nil then -- shirt doesn't exist |
10 | Instance.new( "ShirtGraphic" ).Parent = Character |
11 | wait() |
12 | Character [ "Shirt Graphic" ] .Graphic = "http://www.roblox.com/asset/?id=(ID)" |
13 | else -- shirt exists |
14 | Character [ "Shirt Graphic" ] .Graphic = "http://www.roblox.com/asset/?id=(ID)" i |
15 | end |