Are there server sided function?

i always wondered if there was a way to make events but only server sided to communicate beside all scripts in the server.

Could this be what you’re after?

https://devforum.roblox.com/t/making-events-on-objects/106483/7

2 Likes

i mean like see RemoteEvents, well its only server to client or client to server, well im looking to something that would let me do server to server.

You don’t always need events

If you want the server to communicate with the server
just basically do it all in one script, remotes are not always necessary
Remote Events can ONLY be fired from the client, from the server though you can fire the client for all players using RemoteEvent:FireAllClients
edit :
(Replying to your second post) : Then just end each block and start another what do you mean? You can run both scripts in the loop then

i know but i cant do it in the same script its glitchy and i need it separated. (for ex , 2 while loops)

when i do for ex :

while wait(1) do
script
end

while wait(1) do
script
end

it only do the first loop.

Yes! There is something exactly for this. It is called a BindableEvent / BindableFunction.

It is basically a RemoteEvent/RemoteFunction for same boundary communication.

2 Likes

thank you very much, its Fire() in the topic right?

That is correct. To fire a BindableEvent you simply just call the :Fire method on it with your parameters.

local bindable = Instance.new("BindableEvent")

bindable.Event:Connect(function(a, b, c)
    print(a, b, c)
end)

bindable:Fire("hello", "world", ":)")

NVM its the BindableEvent object

All you have to do is insert a BindableEvent instance and use its .Event signal and :Fire() method. You do not need a RemoteEvent!

Yes, you use Fire for BindableEvents and Invoke for BindableFunctions.

Bindable Events example:

local bindable = Instance.new("BindableEvent")
bindable.Name = 'ServerToServer'
bindable.Parent = game:GetService('ReplicatedStorage'
bindable.Event:connect(function(...)
print("Another script sent me something!", ...)
end)

-- // in another script
game:GetService('ReplicatedStorage'):WaitForChild('ServerToServer'):Fire("gamer", "time", "yes")

Bindable Functions example:

local bindable = Instance.new("BindableFunction")
bindable.Name = 'ServerToServerFunction'
bindable.Parent = game:GetService('ReplicatedStorage'
bindable.OnInvoke = function(...)
	print("Another script sent me something!", ...)
	warn("Maybe I should give them something in return...")
	return game:GetService('HttpService'):GenerateGUID(false)
end

-- // in another script
local result = game:GetService('ReplicatedStorage'):WaitForChild('ServerToServerFunction'):Invoke("gamer", "time", "yes")
print('Bindable returned', result)

You should use BindableFunctions if you want a result back :slight_smile:
Happy scripting!

1 Like

thank you very much for your help :smiley:

You can use a script parented to a bindable event
like

    event  = script.Parent
event.Event:Connect(function()
   print("placeholder")
 end)
 event:Fire("fire event")

Instead of thanking them please mark something as the solution, as to not confuse users

1 Like

You can use spawn() for multiple loops.

1 Like