Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can a server script use :FireServer() ?

Asked by 7 years ago

I'm trying to get 2 server scripts to communicate with each other. Can I use :FireServer() with a server-script? Is there a more efficient way to do this?

1
Nope, that is not possible, simply because events are used to communicate between client and server, what are you trying to do? Newrown 307 — 7y
0
What do you mean by "communicate with each other"? arshad145 392 — 7y
1
Send information from client to server and vice versa Newrown 307 — 7y
0
I'm trying to fire a signal to another script to start an event. How would I do this? User#2146 0 — 7y
View all comments (4 more)
0
No...The op said that " 2 server scripts" , so its obviously not client to server and vice versa...? arshad145 392 — 7y
0
Sorry , I am in a hurry ... Hope this helps... http://wiki.roblox.com/index.php?title=API:Class/BindableEvent arshad145 392 — 7y
0
Will look into it, thank you! User#2146 0 — 7y
0
Oh yeah , one thing the "Bindable Events" will allow server to communicate with each other , but not with localscripts ( clients ) arshad145 392 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

Ok, what you are trying to do is to make both of the server scripts communicate. But what you are doing, using FireServer from a RemoteEvent to communicate between these scripts is wrong. You should only be using a remote event when communicating between server and client. Try using a Bindable event to make communication between two of the same thing possible.

Here is an example. ServerScript1 is trying to give something to ServerScript2. Using BindableEvent, we can send it as an argument to ServerScript2 for it to print.

ServerScript1:


-- ServerScript 1 local Event = game.Workspace:WaitForChild("Event") local Arg1 = "Solution" wait(8) -- a buffer Event:Fire(Arg1)-- call event with an argument

ServerScript2:


-- ServerScript 2 local Event = game.Workspace.Event Event.Event:connect(function(Arg1) -- connect function to event print("Here is the "..Arg1.." !") -- prints out Arg1 end)

Pretty simple concept to understand, right?

Hoped this helped solve your question.

--| astrallife |--

Ad
Log in to vote
0
Answered by 5 years ago

Firstly, why do you want a split server script that calls another? Second, you can only use :FireServer() in a localScript, from Local to Server. Just combine both of the ServerScript into one

For example : So you can't do this

local remote = Instance.new("RemoteEvent")
remote.Name = "HelloThereRemote"
remote.Parent = game.ReplicatedStorage
print("Hello there")
remote:FireServer()

.

local remote = game.ReplicatedStorage:WaitForChild("HelloThereRemote")
remote.OnServerEvent:Connect(function()
    print("Hi there")
end)

Instead of that, do this

print("Hello there")
print("Hi there")
0
I know this is old but I felt the need to say something. He may be trying to prevent what im trying to prevent. If he has a event with cooldown, if the server shuts down during the cooldown the event restarts (Assuming he is giving the event for a DevProduct Purchase) ResoluteAyres 6 — 5y

Answer this question