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

How to fix "FireServer Can Only Be Called From Client" ?

Asked by 5 years ago
Edited 5 years ago
https://gyazo.com/28d8d7b50d0681ca351286a6e253303d

script.Parent.Touched:Connect(function()
    game.ReplicatedStorage.Stage1Check:FireServer()
end)

0
script.Parent.Touched:Connect(function() game.ReplicatedStorage.Stage1Check:FireServer() end) TeoMessiKing -5 — 5y
0
you cant use this method in a local script.. Gey4Jesus69 2705 — 5y
0
dont post comment-worthy answers in the answers section Gey4Jesus69 2705 — 5y
0
sorry good sir sonysunny 36 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

FireServer cannot be fired from a Script. However, it can be fired from a LocalScript.

To check if your script is a Script, click on it and view the properties. Look at the ClassName.

If the ClassName is "Script", then make sure to create a new LocalScript and put it there instead.

To be clear, LocalScripts run on the client (the player's computer), and Scripts run on the server.

For future reference, the following can be done on the server:

FireClient for RemoteEvent from a Script

InvokeClient for RemoteFunction from a Script

OnServerEvent for RemoteEvent from a Script

OnServerInvoke for RemoteFunction from a Script

FireAllClients for RemoteEvent from a Script

The following can be done on the client:

FireServer for RemoteEvent from a LocalScript

InvokeServer for RemoteFunction from a LocalScript

OnClientEvent for RemoteEvent from a LocalScript

OnClientInvoke for RemoteFunction from a LocalScript

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Here's the deal:

The action Fire Server cannot be called from a server script as you must know.

The reason this doesn't work is that Server Scripts are on the server side. Anything on the server-side doesn't need an event! So you do NOT need to fire an event from a regular script. Whenever an action happens from a server script, it automatically replicates to everyone else. On the other hand with a local script, it only replicates to the client. That's the reason it won't work.

Your code is simple to fix. I once thought the same thing but then I learned that you don't need to set up an event for actions used in server scripts.

So overall, all you need to do is move the code. I hope this makes sense. If it doesn't, I will explain:

So first of all, think about it. You're firing an event from a server script then, whenever it's fired, a server script(the same type of script that fired it) receives it. So it wouldn't make sense to have to fire an event from one context level then receive it from the same.

Answer this question