It's for stands datastore in a jojo fighting game. Help please.
I've only tested it on the 1 button but I don't know the issue.
script.Parent.Parent.Parent.CharacterAdded:Wait() local stands = game:GetService("DataStoreService"):GetDataStore("yoyosall") local standsdata = nil local table1 local success, errormessage = pcall(function() standsdata = stands:GetAsync(script.Parent.Parent.Parent.UserId) end) if standsdata then for key, value in pairs(standsdata) do print(key) print(value) script.Parent.Menu["1"].Text = standsdata["1a"] script.Parent.Menu["2"].Text = standsdata["2a"] script.Parent.Menu["3"].Text = standsdata["3a"] script.Parent.Menu["4"].Text = standsdata["4a"] script.Parent.Menu["5"].Text = standsdata["5a"] script.Parent.Menu["6"].Text = standsdata["6a"] script.Parent.Menu["7"].Text = standsdata["7a"] script.Parent.Menu["8"].Text = standsdata["8a"] script.Parent.Menu["9"].Text = standsdata["9a"] print(key) print(value) end end script.Stand.Changed:Connect(function() script.Parent.Parent.Parent.CharacterAdded:Wait() script.Parent.Parent.Parent.Character.Stand.Stand.Value = script.Stand.Value if script.Stand.Value ~= "Standless" then script.Parent.Parent.Parent.Character.Stand.YN.Value = true elseif script.Stand.Value == "Standless" then script.Parent.Parent.Parent.Character.Stand.YN.Value = true end print("1assigned "..script.Stand.Value) wait() table1 = { ["1a"] = script.Parent.Menu["1"].Text, ["2a"] = script.Parent.Menu["2"].Text, ["3a"] = script.Parent.Menu["3"].Text, ["4a"] = script.Parent.Menu["4"].Text, ["5a"] = script.Parent.Menu["5"].Text, ["6a"] = script.Parent.Menu["6"].Text, ["7a"] = script.Parent.Menu["7"].Text, ["8a"] = script.Parent.Menu["8"].Text, ["9a"] = script.Parent.Menu["9"].Text } local success, errormessage = pcall(function() stands:SetAsync(script.Parent.Parent.Parent.UserId, table1) end) end) game.Players.PlayerRemoving:Connect(function(plr2) table1 = { ["1a"] = script.Parent.Menu["1"].Text, ["2a"] = script.Parent.Menu["2"].Text, ["3a"] = script.Parent.Menu["3"].Text, ["4a"] = script.Parent.Menu["4"].Text, ["5a"] = script.Parent.Menu["5"].Text, ["6a"] = script.Parent.Menu["6"].Text, ["7a"] = script.Parent.Menu["7"].Text, ["8a"] = script.Parent.Menu["8"].Text, ["9a"] = script.Parent.Menu["9"].Text } stands:SetAsync(script.Parent.Parent.Parent.UserId, table1) end)
I am not good with datastore, and I got this script from YT. Here is the script I use:
local dataStoreService = game:GetService("DataStoreService") local leaderstatsDataStore = dataStoreService:GetGlobalDataStore("leaderstats") local loaded = {} game.Players.PlayerAdded:Connect(function(player) local leaderstats = player:WaitForChild("leaderstats") if player.UserId > 0 and player.Parent then local leaderstatsdata = leaderstatsDataStore:GetAsync(player.UserId) if leaderstatsdata ~= "Request Rejected" then if leaderstatsdata then for i, stat in ipairs(leaderstats:GetChildren()) do local value = leaderstatsdata[stat.Name] if value then stat.Value = value end end end loaded[player] = true end end end) game.Players.PlayerRemoving:Connect(function(player) local leaderstats = player:FindFirstChild("leaderstats") if leaderstats then if loaded[player] then local leaderstatsData = {} for i, stat in ipairs(leaderstats:GetChildren()) do leaderstatsData[stat.Name] = stat.Value end leaderstatsDataStore:SetAsync(player.UserId, leaderstatsData) end end loaded[player] = nil end)
Hope this helps you understand!!!!