I’m not sure if I follow, but if you’re only just “showing” them the Server ID then there’s nothing wrong with that
They’re just a random player that you wanted to give the Code
to so they can join it
I’m not sure if I follow, but if you’re only just “showing” them the Server ID then there’s nothing wrong with that
They’re just a random player that you wanted to give the Code
to so they can join it
Thats what I wanted to know I didnt know if it was bad or anything to give the server id
Also I know this is off topic but. I got a http 403 for making a reserveserver(), i searched this up and someone said you have to do a pcall, do you think you can help me with this?
Do you have “Enable Third Party Teleports” on? That could possibly be why
Everything is on, yeah. All the settings. (and i do not know how to use pcall)
local success, errorMessage = pcall(function()
id = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
-- do stuff
is this correct? (even if this was correct if it failed it still wouldnt work right, so i dont know why it is doing this)
It should work? Unless if you’re requesting something using HTTPService
, which could result in that error
I believe it’s just due to how your code is made, if you haven’t followed the right parameters & functions TeleportService
give you, it’d result in that HTTP 403 error
The thing is I used the same thing in another script and it worked, is it because I am putting it in a variable? (i have to put it in the variable to get the id of the server unless another way)
You’re probably referencing the id
wrong, cause I see the script you’re using if possible?
Hold on, I am going to try one more thing: Storing it into 2 variables since I just found out it returns 2 values not one.
My other reply wasnt the solution, here is the code.
game.ReplicatedStorage.BuyServerEvent.OnServerEvent:Connect(function(player, serverName, serverType)
local Data = ProfileData:Get(player)
if Data.Server == nil and string.len(serverName) < 25 then
MarketPlaceService:PromptProductPurchase(player, 1173004232)
MarketPlaceService.PromptProductPurchaseFinished:Connect(function(plr, assetId, isPurchased)
if isPurchased then
if assetId == 1173004232 then
local function removespaces(str)
return str:gsub(" ","")
end
local access_code, private_server_id
local type = removespaces(serverType)
local success, errorMessage = pcall(function()
print(game.PlaceId)
access_code, private_server_id = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
print("Success!")
Data.Server = {
ServerName = serverName,
ServerOwner = player.Name,
Id = access_code,
ServerCode = access_code,
PrivateServerType = serverType,
}
print(Data.Server)
end
end
end
end)
end
end)
I’m assuming this could be why…? You never exactly specified a second argument for the private_server_id
variable, which could still be resulted as nil
(Or non-existent)
How do I fix that? What other argument do I use? (also I tried just doing access_code and removing privateserverid and that did not work either.)
I mean you could just remove the parameter, since the private_server_id
can be “read only”
Try that and see if anything changes?
local access_code
local stype = removespaces(serverType)
local success, errorMessage = pcall(function()
print(game.PlaceId)
access_code = TeleportService:ReserveServer(game.PlaceId)
end)
if success then
print("Success!")
so this? also are you sure im not making the function incorrectly (like where “if success then” is supposed to go and stuff.
Yeah that should work, try it and lemme know what you get back
it printed game.PlaceId, it did not print “Success!”
Also should I be testing this in studio or ingame? Just want to confirm I am doing it
Oh I’d wish Id known that, I am going to try it now and see if it works. (It worked thank you!) – I dont know who to mark solution since you both gave me solutions