Hi Developers!
I need help with printing remote event args, I’ve not been able to find out on how to possibly print remote event arguments, I’ve not tried anything because I’ve nowhere to start practically.
Thanks alot and I appreciate it big time!
you use the print()
function.
print(“Hello World”) is the first thing taught in programming. you can get this answer by watching any of the many beginner scripting videos
Can you give me code of this being done?
(I’m recommending that it’d be possible that it’d be like a script being put into a remoteevent)
print(args)
You need to be more specific on what you are trying to do. If you just want to print arguments (anything) you use the print function like shown above. The print function prints to the output the argument(s) passed to it.
Little confused here but are you simply trying to print the arguments fired?
-- client
local First = "Hi"
local Second = "Hello"
local Third = "Greetings"
game.ReplicatedStorage.RemoteEvent:FireServer(First, Second, Third)
--server
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, one, two, three)
print(plr.Name.." fired a RemoteEvent! The args are "..one, two, three)
-- or simply this
print(one)
print(two)
print(three)
end)
I might be a bit vague sometimes, but to give it a little bit more I guess sense I’m trying to fetch arguments for one remote event, like lets say I’ve a remote event in specific I want to track, and then everytime that one remote event fires off, it prints in console with the name of the request and it’s arguments.
By name of the request are you referring to the name of the RemoteEvent?
This is super hard to explain without any knowledge of remoteevents I apologize alot if I’m skipping stuff asjioasdjoagho
The name of the request, if that makes sense?
as @alphadoggy111 and @me said, you just type print(literally_anything_you_want_to_print)
and it will print to the output/console.
I’m going to assume this prints with the arguments exposed also?
arguments exposed to what? if the environment where print(variable) is being called has access to said variable it will print the variable.
Can you show code so we can further assess what the question is?
Here’s an example of how to print something
local variable = "nevergonnagive"
print(variable) --> nevergonnagive
in this example “variable” can be anything. it can be an argument passed through a remote event, it can be a table value. it can be a function, it can be anything
function here
local args = {
WHAT I WANT TO PRINT FROM THE REMOTE EVENT
}
okay so where are you encountering an error or problem?
Can you provide a literal example, like the code structure you’re using?
-- Example
RemoteEvent.Signal:Connect(function(...)
print(...)
end)
I was digging around for a bit and found this:
script.Parent.Event:Connect(function(...)
print(...)
end)
It works but doesn’t print arguments, does this help you at all?
you need to pack variable number of arguments into a table
local function func (...)
local args = {...}
print(args)
end
Edit: nvm you can do it like the next post says and that works too
If it’s not printing any arguments, then that would most likely mean that the event isn’t receiving any arguments:
BindableEvent:Fire(1, 2, 3, 4)
BindableEvent.Event:Connect(function(...)
print(...) -- prints 1, 2, 3, 4
end)
This works perfectly fine! Thanks alot zyro and I appreciate it A LOT!