Remote event not firing

I have a server script that is supposed to fire remote events to clients after a round ends. However, for some reason the client doesn’t seem to be receiving the event at all. I checked that the server script still works (as everything after that line of code still runs) but nothing is printed on the client when I tried using print statements to check. The problem seems to only arise when the remote event is fired after the code RoundEnd.Event:Wait() in the server script below. I’ve tried looking up solutions, but none of them really seemed to be helpful. How would I fix this?

Server script (firing the event, skip until you see a long line of hyphens, that’s where the problem is):

local GameEvents = {
	"Landmines",
	"Guy with rocket launcher",
	"Vent",
	"Ghost",
	"Bomb",
	--"Landmines are spawning, might not wanna stop on 'em",
	--"oh look it's a speeding wall try avoiding it",
	--"lil timmy's are coming, you can jump to get rid of them",
	--"is that a guy with a rocket launcher??",
	--"oops i accidentally dropped some pianos",
	--"Someone received a bomb, pass it around or you're gone!",
	--"Ooh, a spinner!",
	--""	
}

local CurrentEvents = {}

local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local Obstacles = game:GetService("ServerStorage").Obstacles
local GameTextEvent = game:GetService("ReplicatedStorage").Events.GameEvent
local ClientSidedEvent = game:GetService("ReplicatedStorage").Events.ClientSidedEvents
local CleanUpEvent = game:GetService("ReplicatedStorage").Events.CleanUp
local DiedEvent = game:GetService("ServerStorage").Events.Died
local RoundEnd = script.RoundEnd

local Timer = game:GetService("ReplicatedStorage").Instances.Timer

local function CleanUp()
	CleanUpEvent:FireAllClients()
	for _, Instnce in CollectionService:GetTagged("Game") do
		Instnce:Destroy()
	end
	for Index, _ in CurrentEvents do
		CurrentEvents[Index] = nil
	end
end

while true do
	for i = 5, 0, -1 do
		GameTextEvent:FireAllClients("Intermission: " .. i)
		task.wait(1)
	end
	for _, Plr in Players:GetPlayers() do
		Plr.Lives.Value = 3
		Plr.RespawnLocation = workspace.Map.Spawn
		Plr:LoadCharacter()
	end
	for i = 3, 1, -1 do
		GameTextEvent:FireAllClients("Get ready: " .. i)
		task.wait(1)
	end
	Timer.Value = 3
	local CountdownTask = task.spawn(function()
		repeat
			task.wait(1)
			Timer.Value -= 1
		until Timer.Value == 0
		RoundEnd:Fire()
	end)
	local DeathConnection = DiedEvent.Event:Connect(function()
		for _, Plr in Players:GetPlayers() do
			if Plr.Lives.Value > 0 then return end
		end
		RoundEnd:Fire()
	end)
	local Round = task.spawn(function()
		while true do
			local ChosenEvent = GameEvents[math.random(1, #GameEvents)]
			if ChosenEvent == "Landmines" then
				GameTextEvent:FireAllClients("Landmines are spawning, beware not to stop on them.")
				task.wait(5)
				for i = 1, 20, 1 do
					local Landmine = Obstacles.Landmine:Clone()
					CollectionService:AddTag(Landmine, "Game")
					Landmine.Position = Vector3.new(math.random(workspace.Map.Position.X - workspace.Map.Size.X/2, workspace.Map.Position.X + workspace.Map.Size.X/2), workspace.Map.Position.Y + workspace.Map.Size.Y/2, math.random(workspace.Map.Position.Z - workspace.Map.Size.Z/2, workspace.Map.Position.Z + workspace.Map.Size.Z/2))
					Landmine.Parent = workspace
				end
			elseif ChosenEvent == "Guy with rocket launcher" and CurrentEvents["Guy with rocket launcher"] ~= 5 then
				if CurrentEvents["Guy with rocket launcher"] == nil then
					CurrentEvents["Guy with rocket launcher"] = 1
				else
					CurrentEvents["Guy with rocket launcher"] += 1
				end
				GameTextEvent:FireAllClients("Look, it's a guy with rocket launcher!")
				task.wait(5)
				local GuyWithRocketLauncher = Obstacles["Guy With Rocket Launcher"]:Clone()
				CollectionService:AddTag(GuyWithRocketLauncher, "Game")
				GuyWithRocketLauncher.HumanoidRootPart.Position = Vector3.new(math.random(workspace.Map.Position.X - workspace.Map.Size.X/2, workspace.Map.Position.X + workspace.Map.Size.X/2), workspace.Map.Position.Y + workspace.Map.Size.Y/2 + 2.5, math.random(workspace.Map.Position.Z - workspace.Map.Size.Z/2, workspace.Map.Position.Z + workspace.Map.Size.Z/2))
				GuyWithRocketLauncher.Parent = workspace
			elseif ChosenEvent == "Vent" and CurrentEvents["Vent"] == nil then
				CurrentEvents["Vent"] = true
				GameTextEvent:FireAllClients("2 vents will appear, you can travel between them, but don't use them too often or you will become suspicious...")
				task.wait(5)
				local Vent = Obstacles.Vent:Clone()
				CollectionService:AddTag(Vent, "Game")
				Vent.Vent1:PivotTo(CFrame.lookAlong(Vector3.new(math.random(workspace.Map.Position.X - workspace.Map.Size.X/2.5, workspace.Map.Position.X + workspace.Map.Size.X/2.5), workspace.Map.Position.Y + workspace.Map.Size.Y/2 + Vent.Vent1:GetExtentsSize().Z/2, math.random(workspace.Map.Position.Z - workspace.Map.Size.Z/2.5, workspace.Map.Position.Z + workspace.Map.Size.Z/2.5)), Vent.Vent1:GetPivot().LookVector))
				Vent.Vent2:PivotTo(CFrame.lookAlong(Vector3.new(math.random(workspace.Map.Position.X - workspace.Map.Size.X/2.5, workspace.Map.Position.X + workspace.Map.Size.X/2.5), workspace.Map.Position.Y + workspace.Map.Size.Y/2 + Vent.Vent2:GetExtentsSize().Z/2, math.random(workspace.Map.Position.Z - workspace.Map.Size.Z/2.5, workspace.Map.Position.Z + workspace.Map.Size.Z/2.5)), Vent.Vent2:GetPivot().LookVector))
				Vent.Parent = workspace
			elseif ChosenEvent == "Ghost" then
				GameTextEvent:FireAllClients("Spooky ghosts are coming, click them away before they haunt you!")
				task.wait(5)
				ClientSidedEvent:FireAllClients("Ghost")
			elseif ChosenEvent == "Bomb" and CurrentEvents["Bomb"] == nil then
				local AlivePlayers = 0
				for _, Plr in game:GetService("Players") do
					if Plr.Lives.Value > 0 then AlivePlayers += 1 end
				end
				if AlivePlayers > 1 then
					CurrentEvents["Bomb"] = true
					GameTextEvent:FireAllClients("A player has been given a bomb, pass it around before IT EXPLODES!!")
					task.wait(5)
				end
			end
			game:GetService("RunService").Heartbeat:Wait()
		end
	end)
----------------------------------------------------------------------------------------------------------------------------------
	RoundEnd.Event:Wait()
	game:GetService("ReplicatedStorage").Events.Results:FireAllClients({Lives = 1, Duration = 1}, "Stats") -- Testing firing events after the :Wait() code
	if CountdownTask then task.cancel(CountdownTask) end
	DeathConnection:Disconnect()
	task.cancel(Round)
	
	CleanUp()
	
	local Survivors = {}
	for _, Plr in Players:GetPlayers() do
		game:GetService("ReplicatedStorage").Events.Results:FireClient(Plr, {Lives = Plr.Lives.Value, Duration = Plr.Duration.Value}, "Stats")
		if Plr.Lives.Value > 0 then
			Survivors[Plr] = Plr.Name
			Plr.RespawnLocation = workspace.Lobby.Spawn
			Plr:LoadCharacter()
		end
		
		Plr.Lives.Value = 0
		Plr.Duration.Value = 180
	end
	
	GameTextEvent:FireAllClients("Round over!")
	if Survivors then
		game:GetService("ReplicatedStorage").Events.Results:FireAllClients(Survivors, "Survivors")
		game:GetService("ReplicatedStorage").Instances.ShowResults.Value = true
		Survivors = nil
	end
	task.wait(7)
	game:GetService("ReplicatedStorage").Instances.ShowResults.Value = false
end

Local script (receiving the event):

local Player = game:GetService("Players").LocalPlayer
local ResultFrame = script.Parent
local SurvivorList = ResultFrame.SurvivorList
local StatsFrame = ResultFrame.StatsFrame
local ShowResults = game:GetService("ReplicatedStorage").Instances.ShowResults

ShowResults:GetPropertyChangedSignal("Value"):Connect(function()
	ResultFrame.Visible = ShowResults.Value
	if ShowResults.Value == false and #SurvivorList:GetChildren() > 0 then
		for _, v in SurvivorList:GetChildren() do v:Destroy() end
	end
end)

ResultFrame.Visible = ShowResults.Value

game:GetService("ReplicatedStorage").Events.Results.OnClientEvent:Connect(function(Table, Type)
	print(Type) -- print statement not showing up in the console :(
	if Type == "Stats" then
		if Table["Lives"] > 0 then
			StatsFrame.Survived.Text = "Survived"
			StatsFrame.Survived.TextColor3 = Color3.fromRGB(0, 255, 0)
		else
			StatsFrame.Survived.Text = "Died"
			StatsFrame.Survived.TextColor3 = Color3.fromRGB(255, 0, 0)
		end
		StatsFrame.Lives.Text = "Lives left: " .. Table["Lives"]
		StatsFrame.Duration.Text = "Survived for: " .. tostring(math.floor(Table["Duration"] / 60)) .. "m " .. tostring(Table["Duration"] % 60) .. "s"
	elseif Type == "Survivors" then
		for Plr, Name in Table do
			local PlayerText = script.Player:Clone()
			PlayerText.Parent = SurvivorList
			PlayerText.Position = UDim2.new(0, 0, PlayerText.Size.Y.Scale * #SurvivorList:GetChildren(), 0)
			PlayerText.Text = Name
		end
	end
end)

is it not recieving for all the fires for this remote or just one fire

It’s not receiving any of the remote events after that, but it does respond to the change of value of ShowResults in the last few lines of the server script

nevermind i solved the issue apparently the LoadCharacter() is the problem as it deletes and creates a new local script, which in the process of creating it the local script does not connect the OnClientEvent before the server fires the event to it

sorry lol

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