I believe the problem is that the code is running too quickly for the models to load into the game. You need to add WaitForChild()
, or this line of code with each Background:
1 | repeat wait until script.Parent.Background 1 |
2 | local Background 1 = script.Parent.Background 1 |
3 | repeat wait until script.Parent.Background 2 |
4 | local Background 2 = script.Parent.Background 2 |
5 | repeat wait until script.Parent.Background 3 |
6 | local Background 3 = script.Parent.Background 3 |
if you want to use WaitForChild()
, then try this bit of code:
1 | local Background 1 = script.Parent:WaitForChild( "Background1" ) |
2 | local Background 2 = script.Parent:WaitForChild( "Background2" ) |
3 | local Background 3 = script.Parent:WaitForChild( "Background3" ) |
The WaitForChild()
method is clearly more efficient, however both of these will still work, as they both pretty much do the same thing, and wait for the models to load in.
Anyways, I believe the code should work correctly now. If you have any further problems or questions, please leave a comment below. Hope I helped :P