Remote event seemingly not being received

I’m working on a racing system, and I’ve encountered an issue.

The RequestJoin RemoteEvent does not seem to be received by the server. The fired print is printed, but the received print is never printed so I assume the event was never received. Why is the event not being received? Anyone know what’s going on?

RaceManager (Server)

local people = {}
local ppl = 0

while task.wait() do
	wait(15)
	game.ReplicatedStorage.Remotes.ShowRace:FireAllClients()
	print("message sent")
	active = true
	wait(15)

	active = false
	
	--important part past here
	print(ppl.." people")
	if ppl > 0 then
		for i,v in pairs(people) do
			if game.Players:FindFirstChild(v) then
				print("finding cars")
				local char = v.Character
				local hum = char.Humanoid
				local seat = hum.SeatPart

				if string.find(seat.Parent.Name, "Racecar") then
					local car = seat.Parent
					print("finished")
				end
			end
		end
	end
end

game.ReplicatedStorage.Remotes.RequestJoin.OnServerEvent:Connect(function(plr)
	print("received") --not printing
	print(plr.Name)
	if not table.find(people, plr.Name) and ppl < 5 and active == true then
		print("requirements met")
		ppl = ppl + 1
	end
end)

RaceManagerClient (Client)

script.Parent.TextButton.MouseButton1Click:Connect(function()
	local char = game.Players.LocalPlayer.Character
	local hum = char.Humanoid

	if hum.Sit == true and hum.SeatPart ~= nil then
		print("sit")
		game.ReplicatedStorage.Remotes.RequestJoin:FireServer()
		print("fired")
	end
end)

game.ReplicatedStorage.Remotes.ShowRace.OnClientEvent:Connect(function()
	script.Parent.TextLabel.Visible = true
	script.Parent.TextLabel2.Visible = true
	script.Parent.TextButton.Visible = true
	print(2)
	for i = 1,10 do
		script.Parent.TextLabel.Text = "Race starting in "..10-i.." seconds"
		wait(1)
	end
	script.Parent.TextLabel.Text = "Configuring.."
	print(3)
end)

The solution to this would be moving ur while task.wait() do to the bottom

RaceManager (Server)

local people = {}
local ppl = 0

game.ReplicatedStorage.Remotes.RequestJoin.OnServerEvent:Connect(function(plr)
	print("received") --not printing
	print(plr.Name)
	if not table.find(people, plr.Name) and ppl < 5 and active == true then
		print("requirements met")
		ppl = ppl + 1
	end
end)

while task.wait() do
	wait(15)
	game.ReplicatedStorage.Remotes.ShowRace:FireAllClients()
	print("message sent")
	active = true
	wait(15)

	active = false
	
	--important part past here
	print(ppl.." people")
	if ppl > 0 then
		for i,v in pairs(people) do
			if game.Players:FindFirstChild(v) then
				print("finding cars")
				local char = v.Character
				local hum = char.Humanoid
				local seat = hum.SeatPart

				if string.find(seat.Parent.Name, "Racecar") then
					local car = seat.Parent
					print("finished")
				end
			end
		end
	end
end

This is because the loop will always run if you don’t include break inside of it which would break the loop and continue on with the entirety of the script never doing the loop ever again.

1 Like

Thanks, i dont know how i forgot about that

Aha, believe me happens to the best of us.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.