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
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.
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
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.
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.