Weird error: String expected got string

Hello so I want to save the serialized cframes in server inside a folder and an instance value in a player so i have a client script that fires an event which creates that folder and instance value in the server and providing it with the value i passed as a parameter

But it gives me this error which makes no sense
image

client script:

game.ReplicatedStorage.PlayerWon.OnClientInvoke = function()
	
	
	-- player has won

	if not StartTime and #RunRecord <= 0 then
		return
	end

	local CurrentTime = tick() - StartTime


	local BestRuns = Player.BestRuns
	local BestRunRecords = Player.BestRunRecords


	local BestRunForCurrentObby = BestRuns:FindFirstChild(GetRecordPath())
	local BestRunRecordForCurrentObby = BestRunRecords:FindFirstChild(GetRecordPath())
	
	
	local SerializedRecording = ClientFunctions.SerializeCFrames(RunRecord)

	if not SerializedRecording then
		return
	end

	if BestRunForCurrentObby then

		if CurrentTime < BestRunForCurrentObby.Value then			
			game.ReplicatedStorage.ChangePlayerValue:FireServer(BestRunForCurrentObby,CurrentTime)
			game.ReplicatedStorage.ChangePlayerValue:FireServer(BestRunRecordForCurrentObby,SerializedRecording)
		end
	else
		
		game.ReplicatedStorage.CreateInstance:FireServer("NumberValue",GetRecordPath(),CurrentTime,BestRuns)
		game.ReplicatedStorage.CreateInstance:FireServer("StringValue",GetRecordPath(),SerializedRecording,BestRunRecords)
	end


end

ServerScript (which has the error on the 4th line)

game.ReplicatedStorage.CreateInstance.OnServerEvent:Connect(function(Player,Type,Name,v,Parent)
	local Inst = Instance.new(Type)
	Inst.Name = Name
	Inst.Value = v
	Inst.Parent = Parent
end)

Serialize CFrame function which is inside of a module script named ClientScripts

	SerializeCFrames = function(Recording)
		local Serialization = ""

		for _,Frame in pairs(Recording) do
			Serialization ..= tostring(Frame) .. "_"
		end


		return Serialization:sub(1,#Serialization - 1)
	end
1 Like

Try doing tostring(v) (Not sure if it will work but try it anyway ig)
Edit: Read through your code, it should work…

1 Like

Try

Inst.Value = tostring(v)

The serialized cframes is already a string tho

Actually my post won’t work for you, it will interfere with your NumberValue, so disregard my post. Can you do print(typeof(SerializedRecording)) and print(SerializedRecording) in your code? Just post what they send here.

image

Tried adding it but still the same

It isn’t a fix, its just supposed to detect what the value gives…

Also what is ServerScriptService.ServerEvents Line 19?

I mean the tostring(v) fix that you sent earlier not the print statement

The inst.value = value (which is the line 4 of the function)

Yea disregard that post because I didn’t read your code properly. Try doing the prints just to see what is actually being outputted.

the recording is a table of cframes

and the serializecframes should return a string

Just use the print just in case it isn’t what you think it is.

How long is the string? iirc, if the string being set a property is too long, that error is outputted (It’s very strange). If the string isn’t long enough to hit the limit, I’m not sure what the issue could be.

True, esp because position values can be very large because of decimals. You may want to cap the positions to a certain decimal point if you get what I mean.

The string is extremely long cuz it’s a recording of a player’s obby run

I suggest segmenting the string into multiple values, putting the value instances into a folder, and saving the folder as a whole.

You may want to chop it down into individual sections as it’s most likely hitting the maximum limit for a StringValue

1 Like

It’s max size is 200k chars tho and i haven’t gotten the string too long error

Can you try the print? I wanna see what is being outputted.