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?
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.
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.
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)