Help with reserved places

So there is a thing called Reserved Places. I want to do something with them.

Basically I want to create a reserved place and store it in a data store under a certain key, I then want to be able to make it so if someone enters said key into a textbox it then sends them to the reserved place, how can I do this?

Note i have the datastore part down I just need to figure out the reserved places part cause no matter what I tried I couldnt figure it out

Thanks!

2 Likes

To make a new ReservedPlace, use :ReserveServer. It returns the ReservedServerAccessCode you’ll need to join the server. You could save this ReservedServerAccessCode under your key.

Code example:

local TeleportService = game:GetService("TeleportService")

local teleportPlaceId = 123456789

local code = TeleportService:ReserveServer(teleportPlaceId)

local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ReservedServerAccessCode = code

TeleportService:TeleportAsync(teleportPlaceId, {Player1, Player2}, teleportOptions)```
2 Likes

Ok so yay I can generate the server but I need to be able to save it to a Datastore, tried doing it how one might assume,

	local success,err = pcall(function()
		local code = GenerateLobbyCode() 
		
		if not lobbys:GetAsync(code)  then
			server.Place = teleportService:ReserveServer(LobbyId)
			
			
			lobbys:SetAsync(code,server) -- save it!
		end
	end)

But it always says I cant save Dictionaries which you very much can and I have done before so I am assuming it has to do with setting the server.place value to well the reserved server, is there any other way to store it so I can send others there?

1 Like

Also is it possible to send data to the said reserved server? I want to be able to pass a string I have

1 Like

You can use :SetTeleportData.

Documentation:

1 Like

Yes, but it’s unsecured as retrieves the data on the client meaning exploiters can manipulate the data.
You should only be using SetTeleportData to transmit data for use on client.

Any senstive data/data that should be secured for use on server should be Stored in a Memory Store or a Data Store

1 Like

Have you tried using HttpService:JSONEncode?
You should be able to store dictionaries in Datastores, could you please tell me the error message you get while doing it?

1 Like

The error is:

104: CANNOT STORE DICTIONARY IN DATASTORE. DATASTORES CAN ONLY ACCEPT VALID UTF-8 CHARACTERS.

Can you validate your dictionary doesn’t contain any instances? Aswell as all the characters inside it are Valid UTF-8 characters?

I’m pretty sure that the reserved server counts as an instance so is there anyway I can access said reserved server with something else like a code or something?

Question, what is the variable “server”?
Could you tell me what is it, what it for, if it changes what is changed, as well as the print of it

Server is a table which I believe is just this

local server = {
   Place = nil,
}

which in my code from earlier you can see that I set server.Place to the reserved server, considering the reserved server is probably an instance of some form that is probably why it isnt saving, correct me if i’m wrong though.

Just figured out I was storing the player, changed it to just there name Ima see if it works

Oh I see, does your code work now or is it still not working?

Its fixed! I forgot to set the solution! Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.