Chat to Server Event System

I am trying to create a system where through a chat command, I can trigger an action that would happen in every live server (spawning a part, for example). Because ServerScript to ServerScript communication doesn’t exist, how can I achieve this?

Thanks :slight_smile:

Try using MessagingService

Am I able to do this from a LocalScript to a ServerScript? The actions would have to be on the server.

You could use a RemoteEvent that sends a signal to the server. On the server you have to verify the player the signal is coming from has sufficient permission. Then you can use MessagingService as @Chark_Proto said.

You could have presets like “Spawn part” or “Delete building”

I don’t recommend this but you could use loadstring() which will return either a function or nil depending on if the provided string (code) can be converted into a function. Example:

local func = loadstring("print('hi')")
if func then func() end

By default, loadstring isn’t enabled. The only way to enable loadstring is by selecting ServerScriptService in the explore and toggling it in the properties tab. As I said, it isn’t recommended to use loadstring as hackers could take advantage of it, but if you don’t use free models I wouldn’t be concerned. And yeah obviously anyone can use InsertService, so by now when I’m writing this, I don’t think the security vulnerabilities around loadstring should even be taken in to consideration.

1 Like

Do PublishAsync and SubscribeAsync work similar to Fire and ServerEvent for RemoteEvents?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.