Reserved server wont work when using datastore

Hello. when you save a reserved server code on datastore then load it, it wont work the error is:
Unable to cast value to object
is there a way to convert value to object?

What does your code look like? That errors means you tried setting something like a number or string to a parameter that takes an Instance.

i don’t have an actual code im just testing for now

heres my temp code:

script.Parent.MouseButton1Up:Connect(function()
local TS = game:GetService("TeleportService")

local code = TS:ReserveServer(game.PlaceId)
local datastore = game:GetService("DataStoreService"):GetGlobalDataStore()
datastore:SetAsync(0, code)
print("ok")

end)

code 2:

script.Parent.MouseButton1Up:Connect(function()
local TS = game:GetService("TeleportService")
local datastore = game:GetService("DataStoreService"):GetGlobalDataStore()
local e = datastore:GetAsync(0)
TS:TeleportToPrivateServer(game.PlaceId,e,script.Parent.Parent.Parent.Parent)

end)

The 3rd argument should an array of players.

1 Like

the 3rd arg is player its playergui parent

The 3rd argument you provided was a player Instance, not an array.

TS:TeleportToPrivateServer(game.PlaceId, e, {script.Parent.Parent.Parent.Parent})
-- an array is a table of objects or values surrounded by '{}' and their indexes are numerical

It might, if this was the only issue in your code.

1 Like

are you kidding me? so the code that you gave me would solve the problem right???