Remote event is not detected by the server

Hey! So I have a server script and a local script, local script fires a remote and server receives. Yet, there is a chance when the player joins, that the server script does not receive the remote event. Any help with this? The “fired” from the local script is activated, so that tells me its fired, yet I get no “success” or “failure”, nor do I get any errors.

Server Script:

local rep = game:GetService("ReplicatedStorage")
local check = rep.Requests.GroupCheck
local checkP = rep.Requests.GroupCheckP
local checkD = rep.Requests.GroupCheckD
local attri = script.Parent.AttributeController
print("Initialized")


check.OnServerEvent:Connect(function(player)
	if player:GetRankInGroup(16018352) >= 254 then
		print("success")
		local h = attri:Clone()
		h.Parent = player.PlayerGui.ModGUI.Attributes.Main
		h.Enabled = true
		checkP:FireClient(player)
	else
		print("failure")
		checkD:FireClient(player)
		return
	end
end)

Local Script:

local rep = game:GetService("ReplicatedStorage").Requests
local event = rep.GroupCheckP
local ohno = rep.GroupCheckD

rep.GroupCheck:FireServer()
print("fired")

local function onohnoFired()
	print("LOL LOSER!")
	script.Parent:Destroy()
end

local function oneventFired()
	print("It works!!!!!")
end

event.OnClientEvent:Connect(oneventFired)
ohno.OnClientEvent:Connect(onohnoFired)

I think it’s because the client fires the event before the server connects to it.

You should find a way to let the client wait until the server is ready.

Maybe let the server send a RemoteEvent or set a BoolValue to true.
Maybe doing game.Loaded:Wait() will work.

Doesn’t seem to be working, can you give any examples? Not 100% sure on how I’m meant to do this.

Possibly add WaitForChild on the rep. and other paths.

Put it on both, didn’t work. Not sure why

This is what I meant

local rep = game:GetService("ReplicatedStorage").Requests
local event = rep.GroupCheckP
local ohno = rep.GroupCheckD

game.Loaded:Wait() -- or wait here using some other method

rep.GroupCheck:FireServer()
print("fired")

local function onohnoFired()
	print("LOL LOSER!")
	script.Parent:Destroy()
end

local function oneventFired()
	print("It works!!!!!")
end

event.OnClientEvent:Connect(oneventFired)
ohno.OnClientEvent:Connect(onohnoFired)

But I can’t seem to replicate your issue, where did you put the scripts?

That didn’t work, doesn’t even output anything for some reason.
The local script is in Playergui, and the server script is in serverscriptservice.
image
image

I’ve added a button to fire the remote, and I realized that when the original script doesn’t work, the button also doesn’t work.
It seems like there’s something wrong with the event itself?