Difficulty is not a valid member of Folder [Please help]

Greetings, I got an error here but I don’t understand how to solve, because it seems like everything is in order?

Script:
Screenshot 2021-12-29 224644

It is a member?
Screenshot 2021-12-29 224717

The error

Please help! Thanks.

Assuming you’re experiencing this error from a LocalScript, could you please share what you have there? Everything is fine server side.

Well this happens when I am adding a value from a local script such as:
game.Players.LocalPlayer.ServerCreator.Difficulty = 1

I realized I messed something up brb I am going to fix it and come back.

You can use Instance | Roblox Creator Documentation to wait for the instance in case it doesn’t exist when called.

Whenever you want to access an object, you have to wait for it to load. This will solve your issue:

local player = game.Players.LocalPlayer
local serverCreator = player:WaitForChild("ServerCreator") --Wait for the folder to load
local difficulty = serverCreator:WaitForChild("Difficulty") --Wait for difficulty to load
difficulty.Value = 1 --Now that we know everything has been loaded, we can assign it a value!

Remember that Difficulty is a NumberValue (an object), that holds a value. So you need to do difficulty.Value to give it a value.

More information on WaitForChild: Instance:WaitForChild (roblox.com)

1 Like

I am an idiot. I didn’t put .Value and so it didn’t work… Thanks, everyone for trying to find a solution. Btw do you guys know any good methods to sync data between places?

All places associated to the same game share datastores. Whenever you call setAsync on a datastore, it’ll update the datastore’s value for every place in that game.

1 Like

But what if I have different games? The only way I see is through a HTTP request (a website)

Then it gets quite a bit more complex:

Possible to save data across multiple games? - Help and Feedback / Scripting Support - DevForum | Roblox

1 Like

Alright, thank you a lot once again for the help! Have a nice day!

1 Like