I"m making an open world building game and I am using ReservedServers. Whenever someone tries to join a ReservedServer, it errors out saying the place is restricted. Is there something wrong with the code?
clone.JoinButton.MouseButton1Click:Connect(function()
local ui = place.Parent.Parent.LoadUI
if not player:FindFirstChild("Clicked") then
ui.Visible = true
ui.Position = UDim2.new(0, 0, -1, 0)
print("eh")
local TweenService = game:GetService("TweenService")
for _, frame2 in pairs(place:GetChildren()) do
if tonumber(frame2.Name) then
frame2.JoinButton.Interactable = false
end
end
local a = Instance.new("BoolValue")
a.Parent = player
a.Name = "Clicked"
local wframe = ui.WorldFrame
wframe.Names.Text = clone.Names.Text
wframe.Creator.Text = clone.Creator.Text
wframe.WorldThumb.Image = properties.WorldThumbnail
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {}
goal.Position = UDim2.new(0, 0, 0, 0)
local tween = TweenService:Create(ui, tweenInfo, goal)
tween:Play()
local tp = game:GetService("TeleportService")
game.ReplicatedStorage.Files.Events.SetTPUI:FireClient(player)
task.wait(2)
local subPlaceId = 129735425466916
local success, code, privateServerId = pcall(function()
if game:GetService("DataStoreService"):GetDataStore("commentedoutforsafety"):GetAsync(properties.WorldID).ServerId == "0" then
--return tp:ReserveServer(subPlaceId)
return nil
else return game:GetService("DataStoreService"):GetDataStore("commentedoutforsafety"):GetAsync(properties.WorldID).ServerId
end
end)
if not success then
warn("Could not reserve world due to: " .. tostring(code))
for _, frame2 in pairs(place:GetChildren()) do
if tonumber(frame2.Name) then
frame2.JoinButton.Interactable = true
end
end
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {}
goal.Position = UDim2.new(0, 0, -1, 0)
local tween = TweenService:Create(ui, tweenInfo, goal)
tween:Play()
local params = {
buttonCount = 1,
Image = 0,
CloseAllowed = false,
Time = 7,
messageText = "Could not teleport you to the world! Please try again. C01",
button1Text = "Okay",
targetPlayerName = player.Name
}
require(script.Parent.Parent.MessageService).Error(params)
a:Destroy()
return
end
if code ~= nil then
print("Access Code: " .. code)
else
print("No access code, starting NEW server")
end
local success, errorMsg = pcall(function()
local teleopt = Instance.new("TeleportOptions")
local teleportData
if code ~= nil then
teleopt.ReservedServerAccessCode = code
teleportData = {
StartNewServer = false,
WorldID = 0,
NewWorld = false,
WorldInfo = {
Thumbnail = properties.WorldThumbnail,
Creator = game.Players:GetNameFromUserIdAsync(properties.WorldCreator),
Name = properties.WorldName
}
}
else
teleopt.ShouldReserveServer = true
teleportData = {
StartNewServer = true,
WorldID = properties.WorldID,
NewWorld = false,
WorldInfo = {
Thumbnail = properties.WorldThumbnail,
Creator = game.Players:GetNameFromUserIdAsync(properties.WorldCreator),
Name = properties.WorldName
}
}
end
if code == nil then
code = "NONE"
end
teleopt:SetTeleportData(teleportData)
print("Now teleporting " .. player.Name .. " to world " .. properties.WorldName .. " with Access Code " .. code)
tp:TeleportAsync(subPlaceId, {player}, teleopt)
print(teleportData)
end)
if not success then
warn("Could not teleport " .. player.Name .. " to the world: " .. errorMsg)
for _, frame2 in pairs(place:GetChildren()) do
if tonumber(frame2.Name) then
frame2.JoinButton.Interactable = true
end
end
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {}
goal.Position = UDim2.new(0, 0, -1, 0)
local tween = TweenService:Create(ui, tweenInfo, goal)
tween:Play()
local params = {
buttonCount = 1,
Image = 0,
CloseAllowed = false,
Time = 7,
messageText = "Could not teleport you to the world! Please try again. C02",
button1Text = "Okay",
targetPlayerName = player.Name
}
require(script.Parent.Parent.MessageService).Error(params)
a:Destroy()
return
end
end
end)