Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

ReserveServer via chat not working?

Asked by 4 years ago
Edited 4 years ago

After going on the ReserveServer page on the Developer Hub, I decided to tried to recreate what happens in Airplane where people in a specific area get teleported onto a reserved server. But first, I'm trying to make it by chat (It told you how to do it on the ReserveServer Page).

This is what I have so far, but it isn't working.

*Note 1: This is a normal script in Workspace. *Note 2: This is directly copied from the Reserve Server Page except for Lines 8, 9, 10, 18, and 19.

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetGlobalDataStore()

-- Get the saved code
local code = DS:GetAsync("ReservedServer")
if type(code) ~= "create" then -- None saved, create one
    print("Yes")
    code = TS:ReserveServer(4066874124)
    DS:SetAsync("ReservedServer",code)
end

local function Joined(plr)
    -- Everytime they chat, we want to know
    plr.Chatted:Connect(function(msg)
        if msg == "reserved" then -- Aha, that's our cue
            print("Reserved")
            TS:TeleportToPrivateServer(4066874124,code,{plr})
        end
    end)
end

-- Connect all current and future players
Players.PlayerAdded:Connect(Joined)
for k,v in pairs(Players:GetPlayers()) do
    Joined(v)
end

Help is greatly appreciated.

1 answer

Log in to vote
-1
Answered by
sasial 26
4 years ago
Edited 4 years ago

Are there any errors?

What's not working?

Please provide more detail.

1
If you are not posting an explanation please comment instead. Lucke0051 165 — 4y
Ad

Answer this question