Remote Event Does Not Process Given Variables

When firing an remote with the variable (idB) attached, the server does not see this and returns just two player names.

Snippet of code:
(Local script:)

local plr = game.Players.LocalPlayer
local char = plr.Character
local rootp = char:FindFirstChild("HumanoidRootPart")

local function log(plr, idB)
	print(plr, idB) --Returns `PurFusiion 4`
	game.ReplicatedStorage.RemoveEvent:FireServer(idB) --idB will always be a integer
end

while wait() do
	if rootp == nil then
		log(plr, 4)
	end
end

Server sees the event and prints out the statements that sent with the remote with this code (Just as a debug):
(Server script)

listen.OnServerEvent:Connect(print)

Retuns PurFusiion PurFusiion

I want it to return the player name and idB, can anyone help me debug this code?

I think we need to see more code in order to help you out.

1 Like

As Ninja said, we need more code and more of an understanding of exactly what you are trying to achieve. Even going over your post multiple times it’s hard to understand.

What is idB? If this is anything local then it can’t be sent to the server; local part.
Seeing the code:

Your output is BOTH:

Because the event sends the player object by default and idB is already the player object, so you’re already getting exactly what you want. If this isn’t what you want, then you need to fix where you’re setting the variable. Hopefully this helps. :slight_smile:

1 Like

Hi PurFusiion! As Ninja said, more code/information being posted would enable us to better help you. This could just be a bug with where you are defining and or changing the idB variable. RemoteEvents are sometimes tricky and will fail to work if you aren’t defining/changing your variables in the right places. If you could tell us what you want it to print out and what idB is, that would make this much easier.

edit: I just checked this code again, is this idB variable the reason for kicking the player? If it is, make sure this is a string. If you could print(idB) and tell us what the console says, we could help you.

One thing you should know is that the first argument for all RemoteEvent listeners on the server is the Player object that fired the remote. That’s your explanation for why it’s printing PurFusiion first. The second argument, however, may be the name of the player, or the player object itself that you sent from the client.

What exactly is idB? Is it the player’s name? The player object? Something else? Like the others have already said, we need more information/code to help you with this problem.

1 Like

Should be fixed, my mistake. I forgot a few lines due to the DevForums formatting.

No, it wouldn’t. This is actually marginally worse but in concept it does the exact same thing. In your scenario, you’re connecting an anonymous function that is ran when the signal is fired. That function then calls print with the exact same arguments. In this regard, you’re now dealing with the following:

  • Memory being allocated to the anonymous function

  • Code redundancy between two functions

  • Pointless overhead where not necessary

Remember that print is a global function. It is no different from if you declare a function and pass it as an argument to a signal’s connect.

local function myFunction(...)
    print("Starting")
    something:Do()
end

Signal:Connect(myFunction)

---

Signal:Connect(print)

You sir are right, and I’d also like to point out that he has a few typos. Thank you for the insight @ScriptingSupport

along with

and