An issue after creating a datastore

After I have completed scripting a DataStore I came across this error:
** Unable to assign property Source. Provided string length (44357) is greater than or equal to max length (4000)**

2 Likes

There is a limit to the length of a string that you can store in a data store. You also can’t store .source property of scripts or at least you shouldn’t be storing an entire script in your data store lol.

Actually, one more thing. Even though I have removed the DataStore fully, the error message still shows.

Unable to assign property Source. Provided string length (44357) is greater than or equal to max length (4000) - Server
Stack Begin - Studio
Script ‘CoreGui.RobloxGui.Modules.Server.FreeCamera.FreeCameraInstaller’, Line 51 - function AddFreeCamera - Studio
Script ‘CoreGui.RobloxGui.Modules.Server.FreeCamera.FreeCameraInstaller’, Line 120 - function PlayerAdded - Studio
Stack End - Studio

1 Like

You are attempting to assign the .source property of script which I don’t think is allowed… either that or whatever you are assigning the .source property to, it is above the maximum string length. Yeah, I just googled it—you shouldn’t be trying to set the .source property of a script.

I’m not exactly where I have tried to assigned the .source property script, may you give me an example?

Do you have any free models in your game? You might have a bad script.
Example of what it would be like:

local scriptObj = Instance.new("Script")
scriptObj.Name = "GeneratedScript"
scriptObj.Source = [[
	print("Hello, this script was generated by code!")
]]

scriptObj.Parent = game.ServerScriptService

Nope, I don’t have any free models neither I have I typed .Source on any of the scripts. I have checked every script.

Could you provide more details as to when exactly you began to see the error and what you were doing with the datastore that triggered it?

When I finished the dataStore script and as soon I pressed “TEST” the error popped up:

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("MyMilkDataStore")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataTemplate = require(ReplicatedStorage.Data.DataTemplate)

-- Store Player Data in Memory
local PlayerData = {}

-- Creates Copy of Data
local function deepCopy(original)
	local copy = {}
	for k, v in pairs(original) do
		if type(v) == "table" then
			v = deepCopy(v)
		end
		copy[k] = v
	end
	return copy
end

-- When Player Joins
game.Players.PlayerAdded:Connect(function(player)
	local Data
	local succ, err = pcall(function()
		Data = DataStore:GetAsync(tostring(player.UserId))
		if Data == nil then
			Data = deepCopy(DataTemplate)
			DataStore:SetAsync(tostring(player.UserId), Data)
		end
	end)
	
	-- Handle the Result
	if succ then
		print("Successfully loaded data for:", player.Name)
	else
		warn("Failed to load for", player.Name, ":", err)
	end
	
	-- Store the loaded Players Data
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Cartons = Instance.new("IntValue")
	Cartons.Name = "Cartons"
	Cartons.Parent = leaderstats
	Cartons.Value = Data.Cartons
	
	local introDone = Instance.new("BoolValue")
	introDone.Name = "introDone"
	introDone.Parent = leaderstats
	introDone.Value = Data.introDone
	
	-- Simple Command to add 1 Carton
	player.Chatted:Connect(function(message)
		if message:lower() == "/cartons" then
			-- Add Cartons
			player.leaderstats.Cartons.Value = player.leaderstats.Cartons.Value + 1
			
			-- Update Stored Data
			if PlayerData[player.UserId] then
				PlayerData[player.UserId].Cartons = player.leaderstats.Cartons.Value
			end
			
			print(player.Name .. " got 1 carton!")
		end
	end)
end)

-- When Player Leaves
game.Players.PlayerRemoving:Connect(function(player)
	local storedData = PlayerData[player.UserId]
	if storedData then
		
		-- Update with current leaderstats values
		storedData.Cartons = player.leaderstats.Cartons.Value
		storedData.introDone = player.leaderstats.introDone.Value
		
		-- Save Complete Data
		local succ, err = pcall(function()
			DataStore:SetAsync(tostring(player.UserId), storedData)
		end)
		
		if succ then
			print("Data Successfully Saved for", player.Name)
		else
			warn("Data has not been Saved for", player.Name, ":", err)
		end
		
		-- Clean up Memory
		PlayerData[player.UserId] = nil
	end
	
end)

-- Save Data if Player Crashed or Leaves Unexpectedly
game:BindToClose(function()
	
	-- Save All Data
	for _, player in pairs(game.Players:GetPlayers()) do
		local storedData = PlayerData[player.UserId]
		if storedData then
			
			-- Update with current leaderstats values
			storedData.Cartons = player.leaderstats.Cartons.Value
			storedData.introDone = player.leaderstats.introDone.Value
			
			-- Save Complete Data
			local succ, err = pcall(function()
				DataStore:SetAsync(tostring(player.UserId), storedData)
			end)
			
			if succ then
				print("Data Successfully Saved For", player.Name)
			else
				warn("Data has not been Saved for", player.Name, ":", err)
			end
			
		end
	end
	
	wait(3) -- Delay
	
end)

-- Helper Functions
function GetPlayerData(player)
	return PlayerData[player.UserId]
end

function UpdatePlayerData(player, field, value)
	if PlayerData[player.UserId] then
		PlayerData[player.UserId][field] = value
	end
end

hmmm. it must have been an issue on roblox’s end then. See if restarting studio fixes it. Do you see the error in live testing server?

Yep, even after restarting my Roblox Studio it still shows the error.

uhhhhh. this is super weird. Can you do a cntrl shift f and search for “.source” ?

this error randomly popped up after updating studio.
is this a bug? theres no such Property called “Source” I am using in my scripts and I can confirm this by using Find All

2 Likes

okay yeah this is definitely an issue on roblox’s end then. You guys should probably file a bug report if there’s not one already

1 Like

At this point I believe this is a Roblox Studio bug.
I typed it in and No Results Found

1 Like

One thing, what category do you think this falls into for the bug report? Output Window?

1 Like

Not sure lol. Just put your best judgement.

1 Like

you can’t even access the source property outside the command bar and plugins

2 Likes

Got the same issue here too. Definitely not just you. Roblox Bug.

1 Like

Think it just is an roblox bug beceause i got the same issue.

1 Like