Hello, basically I made a tool check on the server. It checks your owned items and clones it to your backpack. However IT WORKS BUT it only works when you reset, not when you initially spawn into the game.
Code:
local function onCharacterAdded(character)
local player = game.Players:GetPlayerFromCharacter(character)
local OwnedItems = player:FindFirstChild("Owned")
local allTools = game.ServerStorage.Resources.Shop
if OwnedItems then
for i, v in pairs(allTools:GetDescendants()) do
if v:IsA("Tool") and OwnedItems:FindFirstChild(v.Name) then
if not player.Backpack:FindFirstChild(v.Name) then
local clone = v:Clone()
clone.Parent = player.Backpack
else
print("Already in backpack: " .. v.Name)
end
end
end
end
end
local function onPlayerAdded(player)
if player.Character then
player:LoadCharacter()
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
game.Players.PlayerAdded:Connect(onPlayerAdded)