Categories > Coding > Lua >
Return instance created with arguments (RemoteEvent/RemoteFunction)
Posted
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
4b5951d5-1b9b-407b-b514-78eb46591564
Replied
@RealNickk
Im converting a FE script I made to a server script and im trying to make Instance.new() work on the server but I cant return the Instance and use it later and Im too lazy to find the Instances manually beacuse yes
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
Replied
@Whoman Oh okay. You need a RemoteFunction to do that, and yes they do support return arguments and accept parameters. Here's an example of arguments (not tested):
local rf = Instance.new("RemoteFunction", game:GetService("ReplicatedStorage"))
rf.OnServerInvoke = function(plr, arg1, arg2)
print(plr, arg1, arg2) --> player Hello World
return "ret"
end
-- Client code:
local rf = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction")
local result = rf:InvokeServer("Hello", "World")
print(result) --> ret
edit: typo
4b5951d5-1b9b-407b-b514-78eb46591564
Replied
Idk man..
https://cdn.discordapp.com/attachments/920343041791905823/984878716175917086/unknown.png
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
Replied
@Whoman .....bruh what
4b5951d5-1b9b-407b-b514-78eb46591564
Replied
nvm I used :Connect() but it still just returns nil..
https://cdn.discordapp.com/attachments/920343041791905823/984880359873327184/unknown.png
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
Replied
@Whoman Are you connecting OnServerInvoke with :Connect? You're not supposed to do that, instead you assign a function to it.
Added
@Whoman hmm, unusual
4b5951d5-1b9b-407b-b514-78eb46591564
Replied
I lost braincells reading this, sorry.
Lua, C# & HTML | Learning C and C++
Exploits I own: Synapse X & Sirhurt
Projects I own/work on: Fume & Ballistic Softworks
Replied
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
Replied
Are you trying to access to an Instance from server that created on client, you cant do that (This is prob not your problem that you asked but your message is nearly impossible to understand)
https://imgur.com/a/oOomuUo
Replied
https://cdn.discordapp.com/attachments/921902131315875872/973268766895001640/Hello_there.png
Whoman#3561 | English & HTML | Learning Lua
Replied
Instructions unclear. I am now mentally deteriorating
Learning how to cheat on roblox
Executors I own: Synapse X, Asshurt/Sirhurt, Scriptware
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )