Remote Function Issue

I am having an issue where my Remote Function is not returning properly. The text on the UI does not change at all, but I know that my if statements are working properly, so I’m not sure what’s going wrong.

Server-Side Script

game.ReplicatedStorage.UnbanPanel.OnServerInvoke = function(plr, username)
	local adminlogs = API2:GetBoardByName("Bondi Rescue Roleplay - Administration Logs")
	local archives = API2:GetBoardByName("Bondi Rescue Roleplay - Ban Archive Board")	
	
	local archivedlist = adminlogs:GetListByName("Archived Bans")
	
	local cardtomove = adminlogs:GetCardByName(username)
	local cardtodelete = archives:GetCardByName(username)
	
	if checkBanned(plr.UserId) == true or checkPermBanned(plr.UserId) == true and cardtodelete ~= nil and cardtomove ~= nil then
	
	cardtomove:Move(archivedlist)
	cardtodelete:Delete()
	
	TempBanStore:RemoveAsync(plr.UserId, "TempBan")
	print("true")
		return true	
	else
	print("false")
		return false	
	end
end

Client-Side Script

bans.UnbanButton.MouseButton1Click:Connect(function()
	local bool = game.ReplicatedStorage.UnbanPanel:InvokeServer(username.TextBox.Text)
	if bool == true then
		bans.CheckLabel.Text = 'One ban found under username "'..username.TextBox.Text..'"'..". Ban has been archived."
	elseif bool == false then
		bans.CheckLabel.Text = 'No bans found under username "'..username.TextBox.Text..'". Please check your spelling and try again.'
	end
end)

Remote Events do not return Values, you would have to use a RemoteFunction

I am using a remote function. That’s why I’m using :InvokeServer() and OnServerInvoke.

Oh my bad, I read it wrong, do you have any sort of error in output?

Nothing. It just prints “true” from the print I used to debug.

You’ll need to extend your debugging here a bit. From the client-side, add a print statement against the return of InvokeServer to see if you are actually getting anything back or not. That’ll tell whether the server is successfully running and returning valid values to the client after invocation completes.

From the server-side, before the last end that closes the function assigned to OnServerInvoke, consider adding a default return value. This can help out in debugging. Temporarily, you may need to make a change on the client that checks if the return is truthy or not after printing the return value as opposed to checking for strict return data.

It’s not really clear to me whether the code is running as expected and it’s just not returning anything, or if you aren’t getting the values you’re expecting. In the client’s case, because it strictly checks for a boolean return, that means it’s getting back a value that’s neither true or false (e.g. nil, number, string, etc) and as such won’t change the text.

Made a dumb mistake. There were 2 TextLabels, UnbanLabel and CheckLabel, and I was changing CheckLabel, when I was meant to be changing UnbanLabel. Thanks for the support anyways.

1 Like