Signal not being received

I’m trying to make voting gui respawn when players die in a round game. The problem, my signals never fire to the client.

Player Loop Code Blocks
	Players.PlayerAdded:Connect(function(player)
		print("Player was added")
		if ServerStatus.Value == "Intermission" then
			Remotes.Voting:FireClient(player,"TurnOn",true)
		end
	end)
	for i,player in Players:GetPlayers() do
		player.CharacterAdded:Connect(function(character)
			print("Character was added")
			if ServerStatus.Value == "Intermission" then
				Remotes.Voting:FireClient(player,"Respawn",true)
			end
		end)
	end

Note: ServerStatus.Value prints intermission yet still doesn’t fire the client and character was added does get printed.

Can you show an example of this?

Try adding a print statement after the value is checked:

if ServerStatus.Value == "Intermission" then
	print("ServerStatus.Value =", ServerStatus.Value)
	Remotes.Voting:FireClient(player,"Respawn",true)
end

Post the script that is listening for the event so we can see it.

Core
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

local Remotes = ReplicatedStorage.Remotes
local ROUND_START = 100
local ROUND_END = 0
local ROUND_UPDATE = 15
local START_TIME = 15
local END_TIME = 0
local MINIMUM_PLAYERS = 1
local VOTING = false

local InRound = require(script.InRound)
local PlayerRemover = require(script.PlayerRemover)
local MapHandler = require(script.MapHandler)
local Colors = require(script.Colors)
local BrickColors = require(script.BrickColors)
local Ending = require(script.Ending)
local Gamemodes = require(script.Gamemodes)
local ServerStatus = ServerStorage.ServerStatus
local CurrentGamemode = ServerStorage.CurrentGamemode

local GamemodeChoices = {
	["Extra Speed"] = 0,
	["Fast Paced"] = 0,
	["Hot Potato"] = 0,
	["No Jump"] = 0,
	["Regular"] = 0
}

local GamemodeNames = {
	"Extra Speed",
	"Fast Paced",
	"Hot Potato",
	"No Jump",
	"Regular"
}

local RoundCounter = 0

local playersInRound = {}

local playersVoted = {}
local playersPressed = {}

local guiGamemodesTable = {}

local Core = {}

function Core:Init()
	local STOP = false
	repeat
		task.wait(1)
	until #Players:GetPlayers() >= MINIMUM_PLAYERS
	ServerStatus.Value = "Intermission"
	Remotes.Voting:FireAllClients("TurnOn",true)
	for i = 1,3 do
		local gam = GamemodeNames[math.random(1,#GamemodeNames)]
		table.insert(guiGamemodesTable,gam)
		if table.find(guiGamemodesTable,gam) then
			for i,v in ipairs(GamemodeNames) do
				if table.find(guiGamemodesTable,v) then continue end
				table.insert(guiGamemodesTable,v)
				gam = v
				break
			end
		end
		Remotes.Voting:FireAllClients("SortGamemodes",gam,tostring(i))
	end
	guiGamemodesTable = {}
	VOTING = true
	local function respawn(player)
		if VOTING == true then
			task.wait()
			Remotes.Voting:FireClient(player,"TurnOn",true)
		end
	end
	Players.PlayerAdded:Connect(function(player)
		print("Player was added")
		if VOTING == true then
			Remotes.Voting:FireClient(player,"TurnOn",true)
		end
	end)
	for i,player in Players:GetPlayers() do
		player.CharacterAdded:Connect(function(character)
			print("Character was added")
			if VOTING == true then
				Remotes.Voting:FireClient(player,"Respawn",true)
			end
		end)
	end
	
	Remotes.Voting.OnServerEvent:Connect(function(player,vote,buttonIndex) -- Play this event in a local server test.
		if typeof(vote) ~= "string" then return end
		if playersVoted[player] and playersVoted[player] == vote then return end
		if playersVoted[player] and playersVoted[player] ~= vote and playersPressed[player] then
			GamemodeChoices[playersVoted[player]] -= 1
			Remotes.Voting:FireAllClients("VoteCount","votes: " .. tostring(GamemodeChoices[playersVoted[player]]),playersPressed[player])
		end
		GamemodeChoices[vote] += 1
		playersPressed[player] = buttonIndex
		playersVoted[player] = vote
		Remotes.Voting:FireAllClients("VoteCount","votes: " .. tostring(GamemodeChoices[vote]),buttonIndex)
	end)

	for i = START_TIME,END_TIME,-1 do
		if STOP == true then break end
		Remotes.ShowStatus:FireAllClients("Intermission: " .. tostring(i))
		task.wait(1)
	end
	Remotes.Voting:FireAllClients("TurnOff",false)
	Remotes.Voting:FireAllClients("Hide","")
	VOTING = false

	playersVoted = {}

	for i,player in Players:GetPlayers() do
		if not table.find(playersInRound,player) then
			player:SetAttribute("IsAlive",true)
			table.insert(playersInRound,player)
		end
	end

	local Map,Pos = MapHandler:Create()
	local FirstColors = BrickColors:Roll(3)
	Colors:ColorMap(Map,FirstColors)
	Colors:Update(Map,FirstColors)
	InRound:Init(playersInRound,Pos)
	ServerStatus.Value = "Round"
	
	local indexName = Gamemodes:Select(GamemodeChoices,playersInRound)
	CurrentGamemode.Value = indexName
	
	local function win()
		if #playersInRound == 1 then
			STOP = true
			Ending:Win(Remotes.Ending,playersInRound)
			if Map then
				local moduleScript = script.Gamemodes:FindFirstChild(CurrentGamemode.Value)
				if moduleScript and moduleScript:IsA("ModuleScript") then
					local currentGamemode = require(moduleScript)
					currentGamemode:Reverse()
					self:Reset(Map)
				end
			end
		end
	end
	
	Players.PlayerRemoving:Connect(function(player)
		if table.find(playersInRound,player) then
			table.remove(playersInRound,playersInRound[player])
			win()
		end
	end)
	
	for i,runner in playersInRound do
		local character = runner.Character or runner.CharacterAdded:Wait()
		character.Humanoid.Died:Connect(function()
			task.wait()
			PlayerRemover:Die(runner,playersInRound)
			win()
		end)
	end
	
	for i = ROUND_START,ROUND_END,-1 do
		if STOP == true then break end
		RoundCounter = i
		if RoundCounter % ROUND_UPDATE == 0 then
			if RoundCounter ~= ROUND_UPDATE then
				local BrickColorsTable = BrickColors:Roll(3)
				Colors:Update(Map,BrickColorsTable)
			elseif RoundCounter <= ROUND_START - ROUND_UPDATE then
				Colors:Update(Map,FirstColors)
			end
		end
		Remotes.ShowStatus:FireAllClients("Round: " .. tostring(i))
		task.wait(1)
	end

	for i,player in Players:GetPlayers() do
		if STOP == true then break end
		if table.find(playersInRound,player) then
			PlayerRemover:Init(playersInRound,player)
		end
	end
	local moduleScript = script.Gamemodes:FindFirstChild(CurrentGamemode.Value)
	if moduleScript and moduleScript:IsA("ModuleScript") then
		local currentGamemode = require(moduleScript)
		currentGamemode:Reverse()
	end
	if Map then
		self:Reset(Map)
	end
end

function Core:Reset(map)
	Remotes.UpdateInfo:FireAllClients("Restart","Color: ","Mode: ",Color3.fromRGB(127, 128, 128))
	ServerStatus.Value = "Intermission"
	RoundCounter = 0
	map:Destroy()
	playersInRound = {}
	for i,player in Players:GetPlayers() do
		if player:GetAttribute("IsAlive") then
			player:SetAttribute("IsAlive",nil)
		end
	end
	for i,v in pairs(GamemodeChoices) do
		GamemodeChoices[i] = 0
	end
end

return Core

I also would like to mention it use to work its just not working anymore.

Nevermind, I fixed it, I just unenabled the ResetOnSpawn property, I have no idea how that worked. I also changed my code a bit here.

	Players.PlayerAdded:Connect(function(player)
		if ServerStatus.Value == "Intermission" then
			Remotes.ErrorHandler:Fire("PlayerAdded",player)
		end
	end)
	Remotes.ErrorHandler.Event:Connect(function(signal,par1,par2) -- Fires when player dies
		if signal == "CharacterAdded" then
			par1.CharacterAdded:Wait()
			Remotes.Voting:FireClient(par1,"Turn",true)
		elseif signal == "PlayerAdded" then
			Remotes.Voting:FireClient(par1,"Turn",true)
		end
	end)

I am not sure what setup you have.

ResetOnSpawn will delete your GUI and replace it with a fresh copy.

So, if you have any variables that linked to the previous GUI then they will not longer work.

You will have to refresh any variables you have defined that are looking for that item.

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