Datastore Cant Find PlayerGui

Didn’t work sadly.

You arent spelling it correctly,

Oh sorry my bad, anyways it still doesn’t work :frowning:

ok look,

You do this:

 -- or this:

Not This:


Plus why are you doing this?

local success, err = pcall(function()
		dataStore:SetAsync(player.UserId, SlotValuesTable) -- Saves player id and the table

	if success then
		print("Data has been saved!")
		print("Data hasn't been saved!")



	local data
	local success, err = pcall(function()

		data = dataStore:GetAsync(player.UserId)


You are supposed to Get the Data first.

Try PlayerGui:WaitForChild(name), StarterGui is where UI is stored BEFORE it is parented into PlayerGui.

I’m not sure if you read the Topic:

Doesn’t that save the data for all players tho?

I was following this thread by the way.

To do DataStore, you have to first Get the Data (:GetAsync()), you are using SetAsync() with no data loaded, plus looking that the thread, you didnt add a function to it

Because you’re trying to access it from the server. This has many flaws. The user can just exploit and change the value. Secondly, you cannot access PlayerGui (I think) from the server as it is not replicated.

  1. That’s how DataStoreService works

  2. You can, the First Variable of PlayerAdded and PlayerRemoving is the player itself, from there you can access the Character, PlayerGui, Backpack, etc

I’m not talking about the player object, I’m talking about PlayerGui…

Yes, but you need access to the player to get access to the PlayerGui

What are you trying to say? I’m saying you shouldn’t be using PlayerGui from the server. You shouldn’t rely or trust the client to get data from it.

Instead, if your data isn’t anything critical, eg settings, you should just have the client send the data over to the server.

Thanks for the notice. This is the output after i added the success detections

Oh ok, the thread used playergui so that’s why I wrote that. But I’m still confused about the situation. The thread used serverstats as an example. And I remember serverstats is inside the player, and so is playergui. but for some reason serverstats can be found but now playergui.

For some reason when I changed the datastore name from “ItemStorage” to “MyDataStore” the script stopped giving me “Data has not been saved!”, but instead gives me this error.

So then I changed
player.PlayerGui.UI.StorageUI.Storage.Row1.Slot1.Slot.Value = data[1]
player.PlayerGui:WaitForChild("UI").StorageUI.Storage.Row1.Slot1.Slot.Value = data[1]
However the script then gave me this error:

I’m not sure what I did wrong.

it turns out that the reason the script kept giving me “unable to assign property value. string expected, got nil” is because the datastore name had a few data that overlapped the current data. I fixed it by changing the datastore’s name, however, I’m again getting the "PlayerGui is not a valid member of Player “Players.sailakedi”.

It turns out that datastores can’t find playergui and playerscripts (even if u add a wait), but can access leaderstats, startergear, and backpack. So instead of putting the stringValues inside playergui, I made a script that will create a folder and then the slots inside the players when they join.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.