RemoteEvent not firing?

I am trying to get user input from a localscript and relay it to a server script using remotes, but either my server script is wrong or the remote isn’t firing
localscript:
local UIS = game:GetService(‘UserInputService’)
local plr = game.Players.LocalPlayer
local navPlus = game.ReplicatedStorage:WaitForChild(“guiNav+”)
local navMinus = game.ReplicatedStorage:WaitForChild(“guiNav-”)
local clickDetector = script.Parent.ClickDetector

function onMouseClick()
	print("a")
	
	navPlus:FireServer()
	
end
 
clickDetector.MouseClick:connect(onMouseClick)

server script:

local NavPlus = game.ReplicatedStorage:WaitForChild("guiNav+")
local NavMinus = game.ReplicatedStorage:WaitForChild("guiNav-")

function A ()
	print("Hello World!")
	
end

NavPlus.OnServerEvent:Connect(A)
1 Like

I changed that line however now I get this:
image

Sorry but that’s wrong, he had that part correct.

@FragmentFour your LocalScript looks like it’s a descendant of workspace. LocalScripts within workspace are only ran if they’re a descendant of the local player’s character.

Keep in mind that ClickDetector.MouseClick fires with a player argument which corresponds to the player who fired the event, you can use the event server-side without having to induce it from a LocalScript at all.

It’s the other way around. OnServerEvent means the server got requested to do something. For RemoteFunctions it makes more sense. OnServerInvoke is when the server is asked for a return value. @fragmentfour is the console logging “A”?

That I understand, however It was previously a userinputservice function, I changed it because I thought it was an issue with that code, here’s what I had before:

	UIS.InputBegan:Connect(function(input,gpe)
 if input.KeyCode == Enum.KeyCode.E and not gpe then -- E
   if (plr.Character.HumanoidRootPart.Position - script.Parent.Position).magnitude <= 10  then -- Dist
navPlus:InvokeServer()
end
end
end)

No, the console isn’t logging anything

It’s a part in workspace, as the original script was to detect if the localplayer is in the part’s magnitude and pressed a key, then it fired the event, however neither a clickdetector or a userinputservice function seems to get the event to fire.

try making the functions local functions

The “local” keyword in scripts is not related to Roblox’ server-client model but rather to variable scoping, that’s not going to help here.

Put the LocalScript into StarterPlayer/StarterPlayerScripts and adapt the reference to the ClickDetector correspondingly.

2 Likes

Thank you! honestly I always thought localscripts could be run anywhere, however this makes a lot more sense.

1 Like