✓ Accepted answer
Instead of having a separate script in every coin, you can just use one script and iterate through all the coins.
While you might do something like this in every coin script that you have:
script.Parent.Touched:Connect(function()
end)
You are able to delete all the scripts in every coin and use just one script (possibly in ServerScriptService), and if you have all coin parts inside a folder/model called Coins in workspace, do something like this:
for _,coin in pairs(workspace.Coins:GetChildren()) do
if coin:IsA("BasePart") then
coin.Touched:Connect(function()
end)
end
end
Also, if you have a large number of small parts that do not require collisions to be calculated on that small of a scale, you can try anchoring them all and setting all their CanCollide to false, and then just use a single invisible part with CanCollide true to act as a boundary.
You can also look here for more reading on improving the perfromance of your game.
1 comment
A good way is to use efficient code as much as possible, and cut down on scripts. (At least that's what I've been told, I think) :)