This is only a fraction of the script, but I think this is the place where it is at fault.
The Table is a table with tool names that the server saved when the player left the game, My problem here is that this script doesn’t give the tools most of the time when the player joins but It prints it like it should.
function LoadTool(PlayerName, Table)
local attempt = 1
print("Loading", Table, " Into", PlayerName)
local playerfolder = folder[PlayerName]
repeat task.wait() until game.Workspace:WaitForChild(PlayerName)
repeat
for _, v in pairs(Table) do
local tool = game.ServerStorage.Bats[v]:Clone()
if tool then
tool.Parent = playerfolder
tool:Clone().Parent = game.Players[PlayerName].Backpack
print("gave", PlayerName, tool.Name)
end
end
--half of the script
I did some optimization that may have helped with the script.
function LoadTool(PlayerName, Table)
local player = game:GetService('Players'):FindFirstChild(PlayerName)
local attempt = 1
print("Loading", Table, " Into", PlayerName)
local playerfolder = folder[PlayerName]
repeat wait() until player['Character']
repeat
for _, v in pairs(Table) do
local tool = game.ServerStorage.Bats:FindFirstChild(v)
if tool then
tool = tool:Clone()
tool:Clone().Parent = player:WaitForChild('Backpack')
tool:Clone().Parent = playerfolder
print("gave", PlayerName, tool.Name)
end
end
if that doesnt work it’s probably a problem somewhere else