The error i get is "data contains object that can't be stored". But it doesn't, all my values being saved are strings and one table. I know this is a lot of code, but it keeps giving me this error even though it should be able to save all the values :/ EDIT: I had cut out a part before because it was too long, apperently it was what breaking this script somehow. I think it's because this creates a function into the table and DataStore can't save functions.

function crew.new(id,name,desc,flag,leader,members)
	local obj = {id=id,name=name,desc=desc,flag=flag,leader=leader,members=members}
	table.insert(allcrew,obj)

	function obj:AddMember(plyr) --This is the part that's breaking the script.
		if type(plyr) ~= "string" then return error("AddMember argument is not a string") end
		table.insert(obj.members,plyr)
		
		CrewStore:UpdateAsync(obj.id,function(oldvalue)
			return obj
		end)
		PlayerCrews:UpdateAsync(plyr.Name,function(oldvalue)
			return obj.id
		end)
	end

	PlayerCrews:UpdateAsync(obj.leader,function(oldvalue)
		return id
	end)
	DataStore:SetAsync(id,obj) -----------This is the line that errors
	return setmetatable(obj,crew_mt)
end

3 comments

0

pls don't use a,b,c = avalue,bvalue,cvalue to assign values, it looks ugly. and also at which line did the output say the error was?

0

I think it looks more organized that way. It's at the last block of code, line 7 (its not actually line 7 in the real script) i also marked it with a comment

0

@DragonODeath It's user preference. It does not affect the efficiency of the code or how the code works.