01 | pants = script.Parent.Pants:GetChildren() |
02 | shirts = script.Parent.shirts:GetChildren() |
03 | faces = script.Parent.Faces:GetChildren() |
04 | hairs = script.Parent.Hair:GetChildren() |
05 | maindummy = game.Workspace.Camera.Dummy_ 3 D |
06 | dummy = script.Parent.Dummy |
07 | repeat wait() until maindummy and dummy and hairs and faces and shirts and pants |
08 |
09 | script.Parent [ "Pant Label" ] .Next.MouseButton 1 Click:connect( function () |
10 | local lastSpawn = nil |
11 | repeat |
12 | local curSpawn = pants [ math.random( 1 ,#pants) ] |
13 | until curSpawn ~ = lastSpawn |
14 | lastSpawn = curSpawn |
15 | wait() --Let the Character fully load |
16 | maindummy.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=" ..curSpawn |
17 | dummy.Pants.PantsTemplate = maindummy.Pants.PantsTemplate |
18 | end ) |
line 16 is errored, Players.Player.PlayerGui.CreateChar.CharChange:16: attempt to concatenate global 'curSpawn' (a nil value)
On line 12, you need to remove 'local'. Using local means that the variable is only stored in that scope -- The repeat block. You need it outside of the repeat block, so it needs to be global. You may also want to set the variable earlier on in the script, not sure if necessary but I can't recall if it isn't.
So, the script:
EDIT: Also, you may want to move the "local lastSpawn = nil" to earlier in the script. The way you have it set up, it will set it to nil every time the button is clicked, which I assume is not the desired effect. If you want it to be a different one each time, you'll want to move it to earlier in the script.
01 | curSpawn = nil |
02 | -- lastSpawn = nil -- Edit: This is what I mean. Add this.. |
03 | pants = script.Parent.Pants:GetChildren() |
04 | shirts = script.Parent.shirts:GetChildren() |
05 | faces = script.Parent.Faces:GetChildren() |
06 | hairs = script.Parent.Hair:GetChildren() |
07 | maindummy = game.Workspace.Camera.Dummy_ 3 D |
08 | dummy = script.Parent.Dummy |
09 | repeat wait() until maindummy and dummy and hairs and faces and shirts and pants |
10 |
11 | script.Parent [ "Pant Label" ] .Next.MouseButton 1 Click:connect( function () |
12 | local lastSpawn = nil -- Edit: ..And remove this. |
13 | repeat |
14 | curSpawn = pants [ math.random( 1 ,#pants) ] |
15 | until curSpawn ~ = lastSpawn |
16 | lastSpawn = curSpawn |
17 | wait() --Let the Character fully load |
18 | maindummy.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=" ..curSpawn |
19 | dummy.Pants.PantsTemplate = maindummy.Pants.PantsTemplate |
20 | end ) |