Remote Event Not Firing

I have a local script and a server script, they are linked together through a remote event in replicated storage. When I press the button, it should print out both messages.
Local script:

script.Parent.Screen.Frame.Button.Activated:Connect(function()
       game.ReplicatedStorage.Hello:FireServer()
       print("hello from client")
end)

Server script:

game.ReplicatedStorage.Hello.OnServerEvent:Connect(function(player)
	print("hello from server")
end)

OUTPUT:

hello from client

Does it seem that the remote event never got fired?

8 Likes

it supposed to print, judging from this situation, you put the serverscript to where it it couldn’t run, so where did you put the serverscript?

7 Likes

If you’re testing in-game instead of in Studio, it’s likely that you won’t see the hello from server message.

2 Likes

I put the serverscript in serverscriptservice.

1 Like

then maybe it is because of what Vetra said, RemoteEvents only work in studio if you have some certain options enabled in the Game Settings

2 Likes

Place the server script in ServerScriptService.

And if that doesn’t work, make sure the event is being fired properly.
Providing a place file would certainly help.

4 Likes

I think I didn’t word my answer correctly, excuse me for that. What I meant was that messages printed from server are likely to not be replicated to client in game.

2 Likes

Try changing this line

game.ReplicatedStorage.Hello:FireServer()

to

game.ReplicatedStorage.Hello:FireServer(game.Players.LocalPlayer)

and check if the capitalization is the same as the remote-event name, I recommend using pcalls aswell.

3 Likes

im talking about your RemoteEvent which only fires if certain options in studio is enabled, it would work fine in game,
also, it printing after :FireServer() doesnt proof that the remoteevent got fired,

2 Likes

RemoteEvents always send the Player who fired the event as first argument.

4 Likes

That’s strange, I’ve never encountered issues with that, I thought only HTTP Requests and DataStores have a option to toggle them.

3 Likes

I have another hypothesis, this may be caused due to Server binding OnServerEvent after Client :FireServer()s it. This issue is possible in ROBLOX Studio, as Studio has a weird script running order. In a real game, this issue will not happen as Server runs before Client.

You could also try to create the remotes from server, using :WaitForChild() in Client, and only set the Parent of the remotes once you’ve binded the OnServerEvent/OnServerInvoke events to a function.

1 Like

I had an issue with this but the reverse - I was firing a remote event from the server but the client sometimes wasn’t receiving it. It seems like remote events that are used on startup need some sort of protocol to make sure the client is listening to it at the time it is called. Likely for you, the client is acting before the server. For longer client loading times, it may be the opposite, so I don’t think creating the event on the server will do much. It seems like RemoteEvent events aren’t cached, although I would have hoped they would be…

What I recommend is using a RemoteFunction to see if the script is listening to the event, since it yields until there is a response. Then you can fire the event. But that’s also feasible just using a RemoteFunction alone. I know RemoteEvents are a lot nicer in that they don’t yield, but it is probably necessary for any events that need to fire at the start of a game.

2 Likes

How did you create the remote?

If you created the remote on the client, the server will not get the event signal because the remote doesn’t exist on the server.

3 Likes

I tested this script putting everything on the position I thought was right and it worked. Here’s the explorer:
Screenshot_1058
If it’s organized in some other way try this one.

Output:
Screenshot_1059

13 Likes

I had the same kind of issue for a while, I would double-check and make sure the Server is listening for the same event that the Client is firing.

2 Likes

Im having the same problem but im using a gui and all my events are in a folder in workspace. I can fire the main event to announce a message but I cannot do any other event. Very Weird

3 Likes

try to use a local script make it a child of the button

1 Like

Try to use this…

Local script:

local Hello = game:GetService("ReplicatedStorage"):WaitForChild("Hello")

script.Parent.Screen.Frame.Button.Activated:Connect(function()
	Hello:FireServer()
	print("hello from client")
end)

Script:

local Hello = game:GetService("ReplicatedStorage"):WaitForChild("Hello")

Hello.OnServerEvent:Connect(function(player)
	print("hello from server")
end)
1 Like

That wouldn’t make a single difference apart from the use of waitforchild
which obviously isnt the issue

2 Likes