it works I think but it says HTTP 403 because I cant teleport to the place I think
Have you tested it with the function or without it?
This should be the script right?
local DataStoreService = game:GetService(“DataStoreService”)
local TeleportService = game:GetService(“TeleportService”)
local ServerAccessCodes = DataStoreService:GetDataStore(“ReservedServerAccessCodes”)
local teleportOptions = Instance.new(“TeleportOptions”)
local PlaceId = “8117862651”teleportOptions.ShouldReserveServer = true
game.Players.PlayerAdded:Connect(function(Player)
print(PlaceId,Player,teleportOptions)
local teleportResult = TeleportService:TeleportAsync(PlaceId, {Player}, teleportOptions)
ServerAccessCodes:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode)
local accssCode = game.PrivateServerId ~= “” and ServerAccessCodes:GetAsync(game.PrivateServerId)
print (“tp ran”)
end)
did it work?
It shows in the console in the game “Unable to cast value to objects” Meanwhile the console in the studio shows “HTTP 403”
o to teleport you got to test in the actual game you know that right?
ServerScriptService that is where it is located at.
I did that but doesn’t still work but I think I got a solution hold on.
Never mind Doesn’t work this is getting pretty weird as to why the script isn’t running as intended.
yeah I dont know either, I’ll keep you updated if I find a solution
Same I’ll try to continue on to find a fix.
you should put tags like “scripting” “Bug” “Help”
So people can find it easier and more people will notice the post
I will thanks for the help anyways.
It worked thank you guys for everything!
What was the change you made into the script
local Plrs = game:GetService("Players")
local TS = game:GetService("TeleportService")
local DSS = game:GetService("DataStoreService")
local SAC = DSS:GetDataStore("ReservedServerAccessCodes")
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
Plrs.PlayerAdded:Connect(function(Player)
task.wait()
SAC:GetAsync("")
local teleportResult = TS:TeleportAsync(8117862651, {Player}, teleportOptions)
SAC:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode)
if game.PrivateServerId ~= "" then
local accessCode = SAC:GetAsync(game.PrivateServerId)
end
end)
Here is the script :
`local players = game:GetService(“Players”)
local DataStoreService = game:GetService(“DataStoreService”)
local TeleportService = game:GetService(“TeleportService”)
local ServerAccessCodes = DataStoreService:GetDataStore(“ReservedServerAccessCodes”)
local teleportOptions = Instance.new(“TeleportOptions”)
teleportOptions.ShouldReserveServer = true
placeid = 8117862651
game.Players.PlayerAdded:Connect(function(Player)
wait(5)
local teleportResult = TeleportService:TeleportAsync(placeid, {Player}, teleportOptions)
print(placeid, players, teleportOptions)
ServerAccessCodes:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode)
local accssCode = game.PrivateServerId ~= "" and ServerAccessCodes:GetAsync(game.PrivateServerId)
print("TP RAN IN THE FUNCTION")
end)
print(“TP RAN”)
`
( this is the script that worked thank you guys for everything!)
Yeah, you just needed to add a yield between the .PlayerAdded event being fired and TeleportAsync() being called on the player instance which caused the event to fire.
you know if your gonna use players at least do players.PlayerAdded:Connect
Should I use my script or yours?