RemoteEvent Firing but not being detected by server

Hi, I am trying to make a script to fire a remote event when I click a certain part.

The remote event fires, as it prints out a statement that I put after it would fire.

Here is my code for the click detector part:

local remoteEvent = game:GetService(“ReplicatedStorage”).BeatQueenBee
script.Parent.MouseClick:Connect(function(player)

remoteEvent:FireClient(player)
print("hello from client")

end)

and for my server script:

local BossTracker = require(game:GetService(“ServerScriptService”).BossTracker) – Get the ModuleScript
local remoteEvent = game.ReplicatedStorage.BeatQueenBee

local function setBoss1Defeat(player)

BossTracker.Data[player.UserId].boss1 = true

print(BossTracker.Data[player.UserId].boss1)
print("Success!")

end

remoteEvent.OnClientEvent:Connect(function(player)
print(“hello from server”)
setBoss1Defeat(player)
end)

It seems as if the server doesn’t detect the remoteevent from firing in the first place. I have the clickdetector as a regular script and the server script as a regular script too. I tried doing this using a local script in startercharacterscripts that would detect if the part has been clicked, but it still doesn’t detect the event from the server.

1 Like

i think you must use fire server to reach the server if you are firing from a client script

1 Like

Tried that but it only gives me an error stating that the remote event can only fire from the client.

It’s because you probably have the code inside of a Script instead of a LocalScript, and inside the workspace. You’ll have to put it in like StarterGui or something and in a LocalScript

Edit: or use a BindableFunction

I tried it with a local script and it did not work. I want to make it so you have to click a certain part in the workspace that will spawn when a certain boss becomes defeated to fire the remote event.

2 Likes

You appear to be using RemoteEvent.OnClientEvent in a server script, not only that but you are also using RemoteEvent::FireClient on the client, it’s supposed to be RemoteEvent::FireServer.

1 Like

Tried it with a OnServerEvent, but it told me that I cant fire a server event from the client.

I tried a local script and did that, and it still didn’t fix the problem.

1 Like

I said this:

abcdefg123

1 Like

So in the click detector script, its supposed to be FireServer? And in the server script its an OnServerEvent?

1 Like

On the client, you use RemotEvent::FireServer, and on the server you use RemoteEvent.OnServerEvent

1 Like

I tried that, but its still giving me this error.
image
image
image

1 Like

So they are both server scripts
your going to need to use a bindable event

1 Like

One is in a click detector and one is in serverscriptservice. How would I do that?

Try changing “FireClient” in the first script to “FireServer”, and “OnClientEvent” in the server script to “OnServerEvent”.

1 Like

well i would suggest using while true do end to see which one is server, if your game crashes then its client

I tried that but its giving me an error stating that it can only be called from the client.

Put a bindable event in ReplicatedStorage or ServerStorage and use

Event:Fire()

On the click detector and

Event.Event:Connect(function()

end)

In the other script

What do you mean by that? What would I have to do?

Make a bindable event in server storage it works the same way as a remote event

yeah just do this

they are both server script so it wouldnt work

Is your script that uses FireServer a LocalScript or a normal Script?