Trouble saving strings to data store

local M3data = DataStore2:GetDataStore("Move3")






local M3 = char.Stats.M3
M3.Name = "M3"

--Check their stand
local myM3

local success, err = pcall(function()
	myM3 = M3data:GetAsync(playerKey)
end)

if success then
	M3.Value = myM3
else
	M3.Value = "generic3"
end
M3.Value = M3data:GetAsync(player.UserId)
--Save their stand
M3data:SetAsync(player.UserId, M3.Value)
M3.Changed:connect(function()
	print("Saving data...")
	M3data:SetAsync(player.UserId, M3.Value)	
	print(player.UserId.."'s data has been saved!")	
end)

	M3.Value = myM3

No idea why its saying this, its pretty much the same script as my other datastores

You haven’t put the script in a playerAdded function(or at least you haven’t showed it).

is this line 164?
is M3 a string value object?

I think what is happening is myM3 is nil, and you are assigning that to a stringValue object causing this error. maybe check that myM3 is a string

if success and type(myM3) == 'string' then

I used tostring, it seemed to solve it