Event Not working

When I run the script nothing shows up I want it to print “working”
My local script

local clickDetector = script.parent

function onMouseClick()
	
	game.ReplicatedStorage.Bro:FireServer()
end

clickDetector.MouseClick:connect(onMouseClick)

Server script

print("Fa")
bro.OnServerEvent:Connect(function(plr)

	print("Worked")
end)

Judging by the code, I assume the LocalScript is located in workspace. In which case, it won’t run

image

4 Likes

Good to know thank you Thank you again

So where should I put the script?

What is the goal here? If I could know that I can help you make something work.

To print something when the player clicks an object I just want the server script to run

Make sure the clickdetector script is a Server Script and is located where it can operate. (e.g. the part itself)
To parse the player, make sure something to identify the player is in the brackets. e.g. function onMouseClick(plr)

Then, you can make some sort of API using remote events.
Make sure there is another Server Script in a location of your choosing, e.g. ServerScriptService.

In that script, you should have something along the lines of this:

print("Working API Receiver")
local remote = game:GetService("ReplicatedStorage").REMOTELOCATIONHERE

function EventReceived(plr)
print(plr.Name .. " has clicked the ClickDetector!")
end

remote.Event:Connect(EventReceived)

Remember, when firing the event make sure to parse the player or the api receiver will error!

remote:Fire(plr)