So I have this Datastore system in my game because I have a matchmacking system and I need to pass the players weapons (that are local scripts) from the one place to the 1v1 place
My code (this code is in both places the same):
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PlayerWeapons")
local SavedWeapons1 = game:GetService("ReplicatedStorage").Scripts
game.Players.PlayerAdded:Connect(function(plr)
local WeaponsData = DataStore:GetAsync(plr.UserId)
local Weapons = plr.Character:WaitForChild("Combat")
if WeaponsData ~= nil then
for i,v in pairs(WeaponsData) do
if WeaponsData:FindFirstChild(v) and Weapons:FindFirstChild(v) == nil then
SavedWeapons1[v]:Clone().Parent = Weapons
for i,v in pairs(Weapons:GetDescendants()) do
v.Enabled = true
end
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local WeaponsTable = {}
for i,v in pairs(plr.Character.Combat:GetDescendants()) do
table.insert(WeaponsTable, v)
end
if WeaponsTable ~= nil then
DataStore:SetAsync(plr.UserId, WeaponsTable)
end
end)
But now if I have the weapons and everything in the first place and then teleport to the 1v1 place nothing is there so the datastore doesnt work and there are no errors in the output.
If you need more information tell me.