When a player respawns in my game, they are automatically given their loadout. This loadout is determined by the team they’re on. The issue I’m experiencing is high ping spikes for a few seconds due to the game cloning and parenting the tool(s) into their backpack. Is there a more efficient way to give players their loadout, and if so, how? When there is multiple players in game respawning at different times, it makes the game somewhat unplayable.
for _, Tool in pairs(Loadout:GetChildren()) do
local Tool_CL = Tool:Clone();
Tool_CL.Parent = Backpack
end
There’s no issue with the code you posted. The issue most likely comes from the scripts you have for your guns. You can confirm this if you just had your loadout be tools with no scripts inside.
I’m guessing you’re cloning a gun tools of some sort which contains thousands lines of code. The problem lies within how your game is structure. This is all assumptions but if your gun / tool has their own scripts then that can cause some problems like performance issues. It’s better to just use 1 script in each tool and that script handles all of the coding shenanigans.