Stringvalue wont update. [Datastore 2]

Hello, I am currently having issues with data not saving stringvalue of Name.
I don’t know how to fix it and been sticking on this book so far.
Code:
Player["Data"].Name.Value = NameData
Error
14:10:48.574 ServerScriptService.Datastore.DataStore:80: attempt to index string with ‘Value’ - Server - DataStore:80
14:10:48.574 Stack Begin - Studio
14:10:48.574 Script ‘ServerScriptService.Datastore.DataStore’, Line 80 - function GetData - Studio - DataStore:80
14:10:48.574 Script ‘ServerScriptService.Datastore.DataStore’, Line 172 - Studio - DataStore:172
14:10:48.574 Stack End - Studio

Get thing
local NameData = PlayerName:Get(Names[math.random(1,#Names)])

Property names have priority over indexing, so the code is assuming you want to get the Name property, which is a string, then you’re trying to get .Value form a string, which doesn’t work. Try renaming what you’re trying to get as there is conflictions as there is a Name property in everything that is an instance

1 Like

I believe the issue here Player["Data"].Value = NameData, you had .Name which is a property of player[“Data”] and so you can’t have .Name.Value

1 Like

It’s not cause of an accidental addition of .Name if the variable name NameData is anything to go by. Likely he has to rename the BaseValue related to the data for the name, as again, property indexing has priority over instance indexing

1 Like

Oh right, my bad.
I think the best way to proceed would be:

local NameData = PlayerName:Get(Names[math.random(#names)])~~

local StringVal = Instance.new("StringValue", player)
StringVal.Name = "RandomPlrName"
StringVal.Value = NameData or toString(NameData) -- Not too sure if the toString() 
                                                 -- is needed

Edit: If my previous reply did help, then you can ignore this code block.