Send object to different server

a object in a server how i send this object to different server
help pls :slight_smile:

I’d be glad to give you a service, but first, could you please:

  1. Click the pencil next to the title to set the topic to #help-and-feedback:scripting-support. Else your post will get taken down!
  2. Could you explain more clearly what you mean by sending to the server please?

EDIT: Great! Your post is safe now.

3 Likes

its my first topic, i have no idea about this :sweat_smile:

im want to send a object to a game server :slight_smile:

This is extremely vague. Do you mean like sending something in the client to the server (a bullet e. g.) ?

EDIT: I read back the title. Do you actually mean like sending a message from a server to another?

no, like a object in a game server i want to send this object to different game server.

Oh, yea, so my edit was pretty right.

You can use MessagingService to do so. Use:

  • MessagingService:SubscribeAsync(Topic, Callback) if you want to recieve messages. Topic is a name you can give for this event, and Callback is the function that occurs when a message is sent.

  • MessagingService:PublishAsync(Topic, Message) if you want to send a message (a table, string, number, etc).

Now for an instance, you could maybe try to make a table with every revelant properties you need. I mean, I only sent tables and strings with this service so far, but I think it won’t hurt anybody to try.

2 Likes

i want send object not string

im not making global chat system

and i can make table in string but i need send module script so i cant set source

I know. Instances are what you call “Objects”. However, you can’t just send instances like that, because they are too heavy to share. You need to only keep what’s important, hence why you need to use a table.

Anyway, would you mind telling me what do you want to acquire?

Oh, and this might be helpful:

i send modulescript if i make property table, i cant set source of modulescript and it will be no work. i need direct send object!

Yea, this is getting tricky. A source would indeed be weighful to send, plus you can’t change source via in-game scripts. What’s inside your module script? Remember that when you do Module.Function(), you are kind of adding the function to the module’s table.

What specifically do you need that for?

1 Like

im tryn to make like ai making a code and its running so i need loadstring

and im make send a data to studio and it will create module script and return to game server

are u understand now? :slight_smile:

What bugs me is: what’s inside the module?

You could simply do as everything fits in a table and so that the module script can know what it should include.

Like:

--[[ BAD EXAMPLE:
local module = {}

function Module:DoScript()
print("everybody do the script")
end
]]

-- GOOD EXAMPLE:

local module = {
        ["DoScript"] = function()
        print("everybody do the script")
        end
}

The good example is simply a table and could be your ModuleScript. Then, send the table via MessagingService, and when the message arrives, just do this:

local LosModulos = {}

local MessagingService = game:GetService("MessagingService")

MessagingService:SubscribeAsync("Foo", function(Message)
       for Name, Function in Message do
              LosModulos[Name] = Function
       end
end)

Not sure if it works, but that would be my idea.

i mean in studio creates modulescript and sets the source to given string and send to game server, this will be loadstring, i think u misunderstood :slight_smile:

I am not misunderstanding. Your concept most likely won’t work if you’re not working on a plugin or something like that. If you want to “create a module script in-game with it’s source set”, you have to use a module script that’s in aptitude to fire and store what you want.

What I suggested you will take the table with every functions you want your module to have (the modulescript you first wished to make), and incorporate into it.

You cannot transfer instances, and mainly scripts, with MessagingService. However, if you make a modulescript in studio and that you want it to be in the server, you can do a script that could convert the module like I did before and send it via messaging service.

bro i cant make string bc if i make how i load the code i need use
require()
for load the modulescript
if i cant transfer the module script it will no work

I’m not your brother tho. :face_with_raised_eyebrow:

What I am suggesting you is to transform the module into a table that can be sent. Then, you use a module that’s already scripted (the new one you’re talking about) that will integrate every variables and functions in the table. Then you can get a module like you wanted to do.

You will be able to require. Indeed, all you’re doing is to add functions to a module that can add them into it.

Just think. If there’s a problem, there has to be a solution.

u cant set a modulescript source in game server, u can set in plugin

I think you’re not understanding.

So basically you have your created module. Instead of using Instance.new(), you clone a premade module with a function that can integrate functions in the table you send. Then boom, you can call module.DoScript(), module.Foo(), module.Bar and all that stuff.

You’re not setting source, you’re just firing a function in the premade module with the table as an argument to add the functions in the table to the premade module. You don’t need to use source.
You are not doing module.Source = "I didn't know source can't be used".

im understand now but u cant send function to a game server.