This was becoming a thread in another post and it was somewhat not relevant to the post I had originally made so I’ll give this a new title.
I have two sets of code, Server, and Client, this is for detecting when the player enters their reserve server, therefore, it will remove the GUI, make the CFrame back to the players, and such. The RemoteEvent was working though it was calling before the player had entered the ReserveServer.
LocalScript:
local Players = game:GetService("Players")
local player = script:FindFirstAncestorOfClass("Player")
local ScreenGui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local MenuMusic = game.SoundService["Distorted Reality Perception - Leon Riskin"]
local Camera = workspace.CurrentCamera
local Players = game:GetService("Players")
local reserve = game.Players.LocalPlayer.PlayerGui.ScreenGui.PlayFrame.GameTypeButton1
reserve.MouseButton1Click:Connect(function(player)
game:GetService("Players").PlayerAdded:Connect(function(player)
game.ReplicatedStorage.RemoteEvent:FireServer()
print("reserved is true for ClientSide")
ScreenGui.Enabled = false
Camera.CameraType = Enum.CameraType.Custom
MenuMusic.Playing = false
end)
end)
Script:
--Variables and code for reserve server stuff
local MainMusic = game.SoundService["Distorted Reality Perception - Leon Riskin"]
local reserve = script.Parent.ScreenGui.PlayFrame.GameTypeButton1
local debounce = false
local ScreenGui = script.Parent.ScreenGui
reserve.MouseButton1Click:Connect(function()
print("starting reserve")
if debounce then return end
debounce = true
local ts = game:GetService("TeleportService")
local access = ts:ReserveServer(game.PlaceId)
ts:TeleportToPrivateServer(game.PlaceId, access, game.Players:GetPlayers())
warn("Teleporting everybody...")
task.wait(5)
debounce = false
end)
local Players = game:GetService("Players")
local player = script:FindFirstAncestorOfClass("Player")
local Camera = workspace.CurrentCamera
local Players = game:GetService("Players")
local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0
game.Players.PlayerAdded:Connect(function(player)
if isReserved == true then
game.ReplicatedStorage.RemoteEvent:FireClient(player)
end
end)