Remote event not receiving

Hey again! The trilogy finale is here! I can’t get my remote event to fire to the client. I tried breakpoints and prints, but I still can’t find the bug. (It prints “Player is not in queue” every time)

Server code:

for i, player in pairs(game.Players:GetPlayers()) do
			if player.InQueue.Value == true then
				SpawnPlayer(player)
				player.Team = nil
				player:WaitForChild("InQueue").Value = false
				player:WaitForChild("InRound").Value = true
				StartRound:FireClient(player)
			else
				print("Player is not in queue") 
			end
		end

Client sided code:

game.ReplicatedStorage.Remotes.StartRound.OnClientEvent:Connect(function()
	print("Recieved!")
	
	script.Parent.Visible = true

	local char = player.Character or player.CharacterAdded:Wait()

	if char then
		print("Char found!")
		
		local Humanoid = char:WaitForChild("Humanoid")

		for i = 5,0,-1 do
			script.Parent.Text = tostring(i)
			print(i)
			wait(1)
		end

		script.Parent.Visible = false

		if player.InRound.Value == true then
			Humanoid.WalkSpeed = 16
		end
	else
		print("Not found")
	end
end)

Does anyone know my issue?

I think it’s because you have to put game.ReplicatedStorage.Remotes.StartRound:FireClient(player)
in the seventh line of your script.

What do you mean? It fires to the client if the player is in the queue. And the players are in the queue on the server.

Wait I know what you mean, but StartRound is a declared variable for a remote.

1 Like

Are you sure the InQueue value is true

2 Likes

Sounds like InQueue.value is false rather than a remote event problem

1 Like

Well, I am really sure, as when my AddQueue event fires, it sets that value to true. It could be the case that it sets both to false at once.

while wait() do
	repeat wait() until #Queue:GetChildren() == 2 and roundStarted.Value == false

	for i, v in pairs(Queue:GetChildren()) do
		
		roundStarted.Value = true
		
		local player = workspace:FindFirstChild(v.Name)

		local pObj = game.Players:GetPlayerFromCharacter(player)
		
		for i, player in pairs(game.Players:GetPlayers()) do
			if player.InQueue.Value == true then
				StartRound:FireClient(player)
				SpawnPlayer(player)
				player.Team = nil
				player:WaitForChild("InQueue").Value = false
				player:WaitForChild("InRound").Value = true
			else
				print("Player is not in queue")
			end
		end

		pObj.Character.Humanoid.Died:Connect(function()
			if roundStarted.Value == true then
				for i, p in pairs(game.Players:GetPlayers()) do
					if p.InRound.Value == true then
						p.InRound.Value = false
						p.Team = game.Teams.Testers
						roundStarted.Value = false
					else
						return
					end
				end
			end
		end)
	end	
	
	for i, q in pairs(Queue:GetChildren()) do
		q:Destroy()
	end

	for i, v in pairs(spawns) do
		if v == true then
			v = false
		end
	end
end

I don’t see you changing it to true in that script

Would you like to see the entire source?

@KingJoseon

--// Roblox Services \\--

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

--// Variables \\--

local Queue = ReplicatedStorage:WaitForChild("Queue")
local Countdown = ReplicatedStorage:WaitForChild("Countdown")

local spawns = workspace.Spawns

--// Remotes \\--

local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local AddToQueue = Remotes:WaitForChild("AddToQueue")
local RemoveQueue = Remotes:WaitForChild("RemoveQueue")
local StartRound = Remotes:WaitForChild("StartRound")

local roundStarted = ReplicatedStorage:WaitForChild("RoundStarted")

--// Functions \\--

local spawns = {
	[workspace.Spawns.P1] = {false},
	[workspace.Spawns.P2] = {false},
}

RemoveQueue.OnServerEvent:Connect(function(player)
	local found = Queue:FindFirstChild(player.Name)
	
	print("Attempting to find player")
	if found then
		print("Found player! Removing ".. player.Name.." from the queue!")
		found:Destroy()
		RemoveQueue:FireClient(player)
		print("Removed ".. player.Name.." from the queue!")
	else
		return
	end
end)

AddToQueue.OnServerEvent:Connect(function(player)
	local sv = Instance.new("StringValue")
	sv.Name = player.Name
	sv.Parent = Queue

	player.InQueue.Value = true
end)

local function SpawnPlayer(player)
	for i,v in pairs(spawns) do
		if v[1] == false then
			v[1] = true
			player.Character:MoveTo(i.Position)
			break
		end
	end
end

while wait() do
	repeat wait() until #Queue:GetChildren() == 2 and roundStarted.Value == false

	for i, v in pairs(Queue:GetChildren()) do
		
		roundStarted.Value = true
		
		local player = workspace:FindFirstChild(v.Name)

		local pObj = game.Players:GetPlayerFromCharacter(player)
		
		for i, player in pairs(game.Players:GetPlayers()) do
			if player.InQueue.Value == true then
				StartRound:FireClient(player)
				SpawnPlayer(player)
				player.Team = nil
				player:WaitForChild("InQueue").Value = false
				player:WaitForChild("InRound").Value = true
			else
				print("Player is not in queue")
			end
		end

		pObj.Character.Humanoid.Died:Connect(function()
			if roundStarted.Value == true then
				for i, p in pairs(game.Players:GetPlayers()) do
					if p.InRound.Value == true then
						p.InRound.Value = false
						p.Team = game.Teams.Testers
						roundStarted.Value = false
					else
						return
					end
				end
			end
		end)
	end	
	
	for i, q in pairs(Queue:GetChildren()) do
		q:Destroy()
	end

	for i, v in pairs(spawns) do
		if v == true then
			v = false
		end
	end
end

If your setting it to true via an event it could be a timing issue, try adding a wait() after calling the add queue event to give it a second to register the new setting

Can you show me the code where it fires AddToQueue

--// Roblox Services \\--

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

--// Variables \\--

local player = Players.LocalPlayer

local Template = script.Template
local Queue = ReplicatedStorage:WaitForChild("Queue")

--// Remotes \\-- 

local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local AddToQueue = Remotes:WaitForChild("AddToQueue")
local RemoveQueue = Remotes:WaitForChild("RemoveQueue")
local StartRound = Remotes:WaitForChild("StartRound")

--// Main UI Objects \\--

local Frame = script.Parent
local Join = script.Parent.Parent.Join
local Leave = script.Parent.Parent.Leave

--// Functions \\--

Join.MouseButton1Click:Connect(function()
	if not Frame:FindFirstChild(player.Name) then
		AddToQueue:FireServer(player)
		script.Parent.Parent.Parent:Destroy()
	else
		script.Parent.Parent.Parent:Destroy()
	end
end)

Leave.MouseButton1Click:Connect(function()
	if Queue:FindFirstChild(player.Name) then
		RemoveQueue:FireServer()
		script.Parent.Parent.Parent:Destroy()
	else
		script.Parent.Parent.Parent:Destroy()	
	end
end)

RemoveQueue.OnClientEvent:Connect(function()
	local QueueDestroy = Frame:FindFirstChild(player.Name)
	
	if QueueDestroy then
		QueueDestroy:Destroy()
	else
		return
	end
end)

Queue.ChildRemoved:Connect(function(removed)
	if Frame:FindFirstChild(removed.Name) then
		Frame:FindFirstChild(removed.Name):Destroy()
	end
end)

RunService.Heartbeat:Connect(function()
	for i, v in pairs(Queue:GetChildren()) do
		if not Frame:FindFirstChild(v.Name) then
			if not Frame:FindFirstChild(v.Name) then
				local newTemplate = Template:Clone()
				newTemplate.Name = v.Name
				newTemplate.Text = v.Name
				newTemplate.Parent = Frame
			else
				return
			end
		end
	end
end)


@KingJoseon there is the source

Update: So I looked at the code more, and I saw that it is spawning the players, but it isn’t firing the event. Then it prints Is not in queue, which I find odd