RemoteEvent not firing?

So, I tried to make a GUI game, and this error occurred: Remote event not firing:
here the local script:

local UIS = game:GetService(“UserInputService”)
local Remote = game.ReplicatedStorage:WaitForChild(“ArrowBind”)

UIS.InputBegan:Connect(function(input, processed)
	if input.UserInputType.Name == "Keyboard" and processed == false then
		if input.KeyCode.Name == Enum.KeyCode.Up then
			Remote:FireServer(1)
		elseif input.KeyCode.Name == Enum.KeyCode.Right then
			Remote:FireServer(2)
		elseif input.KeyCode.Name == Enum.KeyCode.Down then
			Remote:FireServer(3)
		elseif input.KeyCode.Name == Enum.KeyCode.Left then
			Remote:FireServer(4)
		end
	end
end)

and heres the server script:

local Event = game.ReplicatedStorage:WaitForChild(“ArrowBind”)

Event.OnServerEvent:Connect(function(player, arrow)

    script.Parent.Arrow.Value = arrow

    print(arrow)

end)

its really simple and I cant seem to get it.
Both scripts have the same parent.
Any help is appreciated.

@VegetationBush
Ok I see your problem.

In your local script you only are firing a number but in your sever script where you are getting the event you are trying to get player and arrow from it. Both of which are not variables that where sent. TO fix it:

you need to have a variable that defines player and arrow in your local script.
Remote:FireSever(player, arrow, 4)

The first parameter is automatic so you would not need to pass the player and the number that he is giving would be the arrow. I think the problem here is that you wrote

when it should be if input.UserInputType == "Keyboard and processed == false then
you also wrote .Name for the nested if statements

how do i do that? I dont get how you can incorporate player and arrow in it

it’s not, I added a print command to test it out. Nothing came out, but the other way did. Nevertheless, thank you for even helping me.

Ok so.

local player = game.Players.LocalPlayer
local arrow = whatever you have arrow as

Like this?:

local UIS = game:GetService("UserInputService")
local Remote = game.ReplicatedStorage:WaitForChild("ArrowBind")
local player = game.Players.LocalPlayer

UIS.InputBegan:Connect(function(input, processed)
	if input.UserInputType.Name == "Keyboard" and processed == false then
		print("m")
		if input.KeyCode.Name == Enum.KeyCode.Up then
			local Arrow = 1
			Remote:FireServer(player, Arrow, 1)
		elseif input.KeyCode.Name == Enum.KeyCode.Right then
			local Arrow = 2
			Remote:FireServer(player, Arrow, 2)
		elseif input.KeyCode.Name == Enum.KeyCode.Down then
			local Arrow = 3
			Remote:FireServer(player, Arrow, 3)
		elseif input.KeyCode.Name == Enum.KeyCode.Left then
			local Arrow = 4
			Remote:FireServer(player, Arrow, 4)
		end
	end
end)

because it’s still doesnt work

Ok well I cant really help other than that with the information given so, hope you figure it out.

what info should I give then? Should I add screenshots?

You don’t need to use .Name on input.KeyCode, also there’s an Enum for UserInputType.
Here’s the fixed code:.

local UIS = game:GetService("UserInputService")
local Remote = game.ReplicatedStorage:WaitForChild("ArrowBind")

UIS.InputBegan:Connect(function(input, processed)
	if input.UserInputType == Enum.UserInputType.Keyboard and not processed then
		print("m")
		if input.KeyCode == Enum.KeyCode.Up then
			Remote:FireServer(1)
		elseif input.KeyCode == Enum.KeyCode.Right then
			Remote:FireServer(2)
		elseif input.KeyCode == Enum.KeyCode.Down then
			Remote:FireServer(3)
		elseif input.KeyCode == Enum.KeyCode.Left then
			Remote:FireServer(4)
		end
	end
end)

Edit: You don’t need to send the player, the first parameter of a Remote Event fired from a Client is the player who fired it.

1 Like

It doesnt work, as mentioned earlier.

This means that either your server script is in the player or the local script is on the server.
try putting your local script inside StarterGui and the server script inside ServerScriptService
That is probably the main issue but i changed some things that in your scripts too.

Local script:

local UIS = game:GetService("UserInputService")
local Remote = game.ReplicatedStorage:WaitForChild("ArrowBind")

UIS.InputBegan:Connect(function(input, processed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if not processed then
			print("KeyDown")
			if input.KeyCode == Enum.KeyCode.Up then
				Remote:FireServer(1)
			elseif input.KeyCode == Enum.KeyCode.Right then
				Remote:FireServer(2)
			elseif input.KeyCode == Enum.KeyCode.Down then
				Remote:FireServer(3)
			elseif input.KeyCode == Enum.KeyCode.Left then
				Remote:FireServer(4)
			end
		end
	end
end)

Server script:

game.ReplicatedStorage.ArrowBind.OnServerEvent:Connect(function(player, arrow)

    player.PlayerGui.Arrow.Value = arrow

    print(arrow)

end)

the object named “Arrow” should have the same parent as the local script

I hope this helps!

thank you for helping, but, it doesn’t work

You don’t need to send the player when firing remote events, the first parameter of the OnServerEvent function will always be the player, the second parameter will be the first argument you sent to the function, third will be the second, and so on…

“Remote not firing” is not specific enough an error to determine what your problem is. Your code as posted in the OP is fine, so obviously there’s another underlying issue that’s being overlooked here. Please provide the exact error you’re encountering or a hierarchy of your objects for further help debugging.

1 Like

Did you ever try changing the parent? Local scripts can only run in certain places on the client like StarterPlayerScripts and server scripts can only run on the server, like ServerScriptService.

The script looks fine to me. Is that the full script? Is there a loop of any kind before that snippet?
Also if you’re firing the remote to change something on the client, ex under PlayerGui, you should change that in the local script since the server wouldn’t be able to access the player’s guis as far as I know.

As colbert said, it would really help if you showed a picture of where your scripts are located.

As i said in my post before
try moving the Local scripts to the client and the Server script to the server.

I have a print connand in the server script, the event firs just fine, but the server script just doesn’t pick it up. I don’t know why.

Event.OnServerEvent:Connect(function(player, arrow)

    script.Parent.Arrow.Value = arrow

    print(arrow)

end)

it doesn’t print anything, not even a nil

Perhaps you’re listening for the wrong remote event, maybe that’s not the wanted remote event to use .OnServerEvent on
This might even be a connection problem

local script is in starter gui and the server one is in server script service.


sorry the screenshot is bad, I’m using an old comuter right now