For some reason, when running my game, 1 out of 10 times (aproximately), the tool won't be cloned to the backpack when the player connects. No errors in output. Printing "rocket" does return the rocket even when it fails. Am I doing something wrong? is there a better way of doing this? Any suggestion is appreciated:
function LoadData(player)
local rocketStore = DataStore2("rocket", player)
local rocketName = rocketStore:GetAsync(""):andThen(function(rocketName)
if rocketName ~= "" then
local rocket = game.ServerStorage.RocketItems:WaitForChild(rocketName)
if rocket ~= nil then
local clone = rocket:Clone()
clone.Parent = player.Backpack
end
else
local rocket = game.ServerStorage.RocketItems:WaitForChild("rocket 1")
if rocket ~= nil then
local clone = rocket:Clone()
clone.Parent = player.Backpack
end
end
end):andThen(function()
print('get_rocket: success')
end):catch(function(err)
warn("get_rocket: " .. err)
end)
end
game.Players.PlayerAdded:Connect(function(player)
LoadData(player)
end)

1 comment
i would be able to help, but i cant read anything.