RemoteFunction not always returning/recieving

Hello! I’m having a weird error that for days I’ve been trying to fix. Below is the code that activates when a RemoteFunction in ReplicatedStorage is fired. The issue is, it doesn’t always return/receive. What I mean by this is *1 always prints, *2 print rarely like per server, so in studio it can work but it also cannot, like a 1/5 chance.

The returns return empty strings (nil) for the times it doesn’t work, and it literally makes no sense as to why it wouldn’t work. If anyone could help me that’d be amazing.


RemoteFunction Handler Script
print("hello") -- *1

game.ReplicatedStorage.Functions.Function.OnServerInvoke = function(Player,Type,Data)
	print(Player) -- *2
	print(Type) -- *2
	print"hellO" -- *2
	if Type == "HasPass" then
		return game.MarketplaceService:UserOwnsGamePassAsync(Player.UserId,7213132)
	elseif Type == "GroupRank" then
		return Player:GetRankInGroup(4313692)
	elseif Type == "IsInGroup" then
		return Player:IsInGroup(4313692)
	elseif Type == "UserHasSpecificPass" then
		return game.MarketplaceService:UserOwnsGamePassAsync(Player.UserId,Data["GamepassId"])

RemoteFunction Location

Example Call

View Example
if game.ReplicatedStorage.Functions.Function:InvokeServer("HasPass",nil) == true then
	if workspace.PremiumExclusionZone then
		game.Players.LocalPlayer.PlayerGui:FindFirstChild("Premium").Adornee = nil

There are no errors except for the error saying a number can’t be calculated with a number and a nil value.

I’m sorry if I’m breaking any rules. This is my second time as an OP.

1 Like

I don’t notice anything wrong with this so far. Here are a few things I did note:

I had a weird issue in the past where a remote function was not receiving any data I sent to it. It turned out that the code in the script above it was halting and therefore the function was never being set to OnServerInvoke. Is there any code above your server side function that could stop it being attached to the RemoteFunction?

Another thing I noticed is that your function in RemoteFunction Handler script does not have a return for every case. For example if all the if-s and elseif-s do not pass, nothing is returned.

No that was the entire script. I put an else at the end of the elseif tower with just a return, but didn’t solve it.

No, they’re essentially RemoteEvents that return something. It can be anything, objects, strings, tables, integers etc.

Found the thing going wrong I think. Appears that a script may have been creating an instance in ReplicatedStorage with the name “Function”. The weird thing is I don’t know any scripts that would do it other than CheckMeIn (god I need to replace), or Roblox itself. Anyway thanks @Naco88 for trying to help!

– Edit

Wasn’t the issue apparently.

1 Like