I’m making a building game where players get their own plots assigned to them. I wanted each player’s plot to have its own PartLimit (To prevent lag), I initially thought I could do this by just using a value to update to the plot’s part count but it doesn’t seem to be working for some reason.
This is my explorer,
and this is the script.
Basically the script gets the descendants of the build folder (Where all the parts go) and counts them up, setting the counter to the “PartCount” value. I’m using descendants in case a player groups parts together.
Whenever I press play I just get an error message and nothing happens,
I’m relatively new to scripting so I don’t seem to understand this issue yet. If anyone could help me out it would be extremely appreciated. I’m just looking for a way to fix this or even possibly use another way.
Just a heads up, in that screenshot I changed the script to GetChildren() to see if that was part of the issue, it wasnt. The original script uses GetDescendents().
In a while loop, you must use wait() to prevent the loop from running too fast, thus creating that error.
You should use partCount = script.Parent then add .Value to the end of each reference to it because accessing its value gives a copy of it’s value, not itself
Also I recommend changing partCount = partCount + 1 to partCount += 1 to make it easier to read