Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making Sure Player has Clothes?

Asked by 5 years ago
Edited 5 years ago
01--------------------------------------------------------------------
02Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=(ID)"
03-----------------------------------------------------------------------------
04 
05Character.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)"
09end
10 
11Character["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)"
15end

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

0
Oh, and I did add template IDs to the (ID) parts LegoUnicornRoblox 37 — 5y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

01Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=(ID)"
02 
03Character.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)"
07end
08 
09if 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)"
13else -- shirt exists
14    Character["Shirt Graphic"].Graphic = "http://www.roblox.com/asset/?id=(ID)" i
15end
0
I see that. Although, your check for if the shirt graphic needs to be before line 11 since that is where the script errors. I'll edit the answer to show how to fix that. royaltoe 5144 — 5y
1
Thank you so much LegoUnicornRoblox 37 — 5y
Ad

Answer this question