You can write your topic however you want, but you need to answer these questions:
Hey everyone I’m working on a main menu GUI with save/load slots and it current loads/saves the player’s data as intended, but I want the slots on the main menu to show the players stats from the different datastores (Stats2,Stats3,Stats4,Stats5,Stats6). The problem is I can’t seem to get the player’s values from the different datastores to populate the GUI, I’ve even added message blocks into my script to let me know if anything is failing and I get nothing and zero error messages as well. Below is the local script that is inside my menu GUI and a short clip of the issue. All I’m looking for is a way to pull values from exsisting datastores to my GUI so players can see exactly what slot they’re loading into.
-- local frame = script.Parent
local Slot1 = frame.LOAD1
local Slot2 = frame.LOAD2
local Slot3 = frame.LOAD3
local Slot4 = frame.LOAD4
local Slot5 = frame.LOAD5
local BackB = frame.Back
local Gold1 = frame.Gold1
local Gold2 = frame.Gold2
local Gold3 = frame.Gold3
local Gold4 = frame.Gold4
local Gold5 = frame.Gold5
local Level1 = frame.Level1
local Level2 = frame.Level2
local Level3 = frame.Level3
local Level4 = frame.Level4
local Level5 = frame.Level5
local Rank1 = frame.Rank1
local Rank2 = frame.Rank2
local Rank3 = frame.Rank3
local Rank4 = frame.Rank4
local Rank5 = frame.Rank5
local School1 = frame.School1
local School2 = frame.School2
local School3 = frame.School3
local School4 = frame.School4
local School5 = frame.School5
function updateGUI(player)
local success, data = pcall(function()
return game:GetService("DataStoreService"):GetDataStore("Stats2"):GetAsync(tostring(player.UserId))
end)
if success then
-- Check if the Gold value is present in the data
if data and data.Gold ~= nil then
Gold1.Text = "Gold: " .. data.Gold
else
Gold1.Text = "Gold: N/A"
end
else
warn("Failed to load data from DataStore for " .. player.Name)
end
end
-- Connect to the PlayerAdded event
game.Players.PlayerAdded:Connect(function(player)
updateGUI(player)
end)
-- Button click events
-- ...
BackB.MouseButton1Click:Connect(function()
script.Parent.Visible = false
script.Parent.Parent.Background.Visible = true
end)
Showcase.wmv (771.0 KB)