RemoteEvent not calling

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)
1 Like

I apologize, I was eating.

Local Script


local Players = game:GetService("Players")


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 player = game.Players.LocalPlayer

local reserve = game.Players.LocalPlayer.PlayerGui.ScreenGui.PlayFrame.GameTypeButton1



	
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function() -- If this is called then we know it is a reserved server.
	print("reserved is true for ClientSide")
	ScreenGui.Enabled = false
	Camera.CameraType = Enum.CameraType.Custom
	MenuMusic.Playing = false

end)
2 Likes

this has not worked and no errors :((

I am not sure at this time what the problem is, sorry.

2 Likes

I think you need to add a wait statement to allow time for the client to load in.

2 Likes

Sadly this hasn’t worked, not really sure but i guess the client isnt firing to the local script.

Have you tried adding a print() to your conditional statement to see if isReserved is actually true?

if isReserved == true then
	game.ReplicatedStorage.RemoteEvent:FireClient(player) 
print("OK")
end

If that doesn’t output anything the issue is with the logical operation while indexing isReserved.

1 Like