Remote event not firing while using a print function

Hi there, I am testing with remote events and my idea here, is to print a line out after the part is clicked, which fires a remote event. The problem here, is that the remote isn’t firing and the server is not receiving the click from the client. Note that the fire remote script is client and the onserverevent is server.

local

local part = script.Parent
local remote = game.ReplicatedStorage:WaitForChild("test")

local function test()
	remote:FireServer()
end

part.ClickDetector.MouseClick:Connect(test)

server

local remote = game:GetService("ReplicatedStorage"):WaitForChild("test")

local function fired()
	print("done")
end

remote.OnServerEvent:Connect(fired)
local remote = game:GetService("ReplicatedStorage"):WaitForChild("test")

local function fired(player)
	print("done")
end

remote.OnServerEvent:Connect(fired)

Do I have to define player too?

Player is a parameter, u dont need to define it.

Alright, also i changed it to that and it still doesn’t print.

May I know the location of the scripts?

Local script is under the part, which is in workspace. Serverscript is in serverscriptservice

Place local script under StarterPlayerScripts otherwise it won’t run.

Alright.

ClickDetector is not a valid member of Script "Workspace.test"

ClickDetector is part of the part? I also changed it to waitforchild and still no solution

Well, the error says that workspace test is a Script

Then what could be the issue here? If I removed the fire part in the local script and replaced it with a print function, it prints, but not with firing the remote. The remote is also in replicatedstorage.

However, it only works if the local script is in the part

Send me the heirarchy/pic of workspace

image
image

You didn’t place the script under starter player scripts.

I did, but the error only showed up when it was placed there.

Place it there and update the code(client):

local part = workspace:WaitForChild("test")
local remote = game.ReplicatedStorage:WaitForChild("test")

local function test()
	remote:FireServer()
end

part.ClickDetector.MouseClick:Connect(test)
local click = script.Parent

local function test()
	print("done")
end

click.MouseClick:Connect(test)

You don’t need two scripts, this would be a server script placed inside the ClickDetector instance.

He pointed out he was testing with RemoteEvents.