Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

FireServer can only be called from client?

i dont know what to put in here as im already confused all i did is ad a remoteevent on replicatedstorage then adding a local script inside the RemoteEvent with this piece of code:

local RemoteEvent = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))

Gl.

2 answers

You can only fire a remote with the FireServer from the client. When firing the server, you need a OnServerEvent event connected to a function in the server for the event to be triggered.

Example:

Local Script:

local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent:FireServer() 

Server Script:

local RemoteEvent = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))

RemoteEvent.OnServerEvent:Connect(function(player, args)
	print(player.Name .. "has fired the remote event) -- player is a default parameter that returns which player fired the remote. 
end)

1 comment

0

Dosent Work

If your adding the Remote Event in ReplicatedStorage with a normal script you don't have to add it in again with a local script. You are getting that error because somewhere in your normal script it is trying to fire the remote event. You can only fire the Server from the client(local script) and vice versa, you can only fire the Client(Player) from the Server If you got nothing of what I just said, just don't use FireServer in a normal server script, you have to use it in a local script.

1 comment

0

i used a local script? i idd Remote Event and inside it i placed a local script with the code

This discussion is preserved as it was. New answers, comments, and votes are closed.