RemoteEvents never firing

I have a Remotes module (Library.Remotes):

local Remotes = {}

local RemotePath = game.ReplicatedStorage.Remotes
local Side = game:GetService("RunService"):IsServer() and "Server" or "Client"

function Remotes.Fired(id)
	id = string.lower(id)
	local remote = RemotePath:FindFirstChild(id)
	if not remote then
		remote = Instance.new("RemoteEvent")
		remote.Parent = RemotePath
		remote.Name = id
	end
	if Side == "Server" then
		return remote.OnServerEvent
	else
		return remote.OnClientEvent
	end
end

function Remotes.Fire(id, ...)
	id = string.lower(id)	
	local remote = RemotePath:FindFirstChild(id)
	if not remote then
		remote = Instance.new("RemoteEvent")
		remote.Parent = RemotePath
		remote.Name = id
	end
	if Side == "Server" then
		remote:FireClient(...)
	else
		remote:FireServer(...)
	end
end

function Remotes.FireAll(id, ...)
	for _, v in pairs(game:GetService("Players"):GetPlayers()) do
		Remotes.Fire(id, v, ...)
	end
end

function Remotes.Invoked(id, callback)
	id = string.lower(id)
	local remote = RemotePath:FindFirstChild(id)
	if not remote then
		remote = Instance.new("RemoteFunction")
		remote.Parent = RemotePath
		remote.Name = id
	end
	if Side == "Server" then
		remote.OnServerInvoke = callback
	else
		remote.OnClientInvoke = callback
	end
	return remote
end

function Remotes.Invoke(id, ...)
	id = string.lower(id)
	local remote = RemotePath:FindFirstChild(id)
	if not remote then
		remote = Instance.new("RemoteFunction")
		remote.Parent = RemotePath
		remote.Name = id
	end
	if Side == "Server" then
		return remote:Invoke(...)
	else
		return remote:InvokeServer(...)
	end
end

return Remotes

I’m working on the gamepass system and when I try to fire to the server using this module, nothing happens. This also happens with FireAll (Equivalent of RemoteEvent:FireAllClients). I have a feeling this is caused by the Remotes module. Upon checking Explorer while in a session, I have noted that the event I need (Gamepass Purchased) is present, but the event connected to it never runs. Does anyone know what is causing this?
P.S.: If anyone needs to see where I’m firing to and from, please ask :slight_smile:

Hi, is there anything showing in output?

Hello! No, there is nothing in output. I’ve put print statements around the Remotes.Fire call, and they show in output, as well as all the code after it, but the print statements inside of the connected function don’t show in output. There are no errors.

Can you show where & how you are firing the remotes?

Absolutely:
LocalScript in SPS:

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plyr, id, wasPurchased)
	print("PGPPF fired")
	if wasPurchased then
		local gpName
		for k, v in pairs(Library.Shared.Gamepasses) do
			local check = v.ID or nil
			if not check then
				continue
			else
				if check == id then
					gpName = k
				end
			end
		end
		print(gpName)
		if not gpName then
			GUI.Statement("Oops! There was an error finding that gamepass. If you've paid Robux, you will receive your gamepass very shortly. We're sorry!")
			return
		end
		Remotes.Fire("Gamepass Purchased", plyr, gpName)
		GUI.Statement("Thank you so much for supporting the game! We sincerely appreciate it! 😁")
	else
		GUI.OpenGUI(Shop)
	end
end)

Connected to a function in Gamepasses, a script in SSS:

Remotes.Fired("Gamepass Purchased"):Connect(function(plyr, id)
	print("Gamepass Purchased fired")
	local owns = Gamepasses.PlayerOwnsGamepass(id, plyr)
	if not owns then
		Remotes.Fire("Statement", plyr, "Oops! There seems to be an inconsistency. 	Remote Gamepass Purchased was fired but you don't own the gamepass. If you don't know anything about this, feel free to carry on.")
		return
	end
	
	local gamepass = Library.Shared.Gamepasses[id]
	if gamepass.Callback then
		gamepass.Callback(plyr)
	end
	
	local save = Saving.Get(plyr)
	print(save)
	if save then
		table.insert(save.Gamepasses, id)
	end
end)

One important thing to note is that I’m using a custom module to create, fire and connect these. The code is in the question body. It’s likely that the culprit is that.

I’ve fixed the issue! Turns out it was firing, but because I was using a local server the server print statements weren’t showing in the output of the client. I feel really stupid now :confused:

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