How do I use 1 remote event/function

  1. What do you want to achieve? Keep it simple and clear!

I want to know how to use a remote event or remote function once.

  1. What is the issue? Include screenshots / videos if possible!

I don’t know how to assign specific parameters for each time I’m firing to that remote event/function.

local UIS = game:GetService("UserInputService")
local CS = game:GetService("CollectionService")
local RS = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local debounce = false

--Player stats
local plr = players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local HRP = char.PrimaryPart
local hum = char:WaitForChild("Humanoid")

for i, v in pairs(CS:GetTagged("Wall")) do
		if not debounce then
			debounce = true
			local params =
			params.FilterDescendantsInstances = {char}
			params.FilterType = Enum.RaycastFilterType.Exclude
			local origin = HRP.Position
			local direction = HRP.CFrame.LookVector * 3
			local raycast = workspace:Raycast(origin,direction, params)
			if raycast then
				local attach = RS:WaitForChild("Climb"):InvokeServer("Touch")
				if attach == true then
					debounce = false

local function movebutton(input)
	if input.KeyCode == Enum.KeyCode.W or Enum.KeyCode.A or Enum.KeyCode.S or Enum.KeyCode.D then
		local controlstable = {
			W = HRP.CFrame.UpVector * 16,
			S = HRP.CFrame.UpVector * -16,
			A = HRP.CFrame.RightVector * 16,
			D = HRP.CFrame.RightVector * -16,	
		local control = controlstable[input.KeyCode.Name]
local function stop(input)
	if input.KeyCode == Enum.KeyCode.W or Enum.KeyCode.A or Enum.KeyCode.S or Enum.KeyCode.D then


In here you can see 3 functions being fired to the server and 1 having an extra parameter. The problem is when that parameter runs, it turns out as nil.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried using more if statements but I’ve never tried to make a game with one remote event/function.

Make sure to always pass the player as the first parameter on the OnServerEvent event or OnServerInvoke.

Remember that the server recieves the player as the first argument, the parameter you send in the client, would be the second. Example:




Result ( PlayerName, "hello)

Yeah I passed the plr as the first parameter.

RemoteFunctions return values btw, I believe that you should use RemoteEvents for this instead.

Keep in mind the 1st parameter passed is always the player. So no matter what you call it … in this case input that will be the player … you want (player, input) even if you’re not going to use player for anything.

You dont have to pass the player if you are firing from the client to server, the server receives the first parameter as player

Can you share the part of the server script?

local RS = game:GetService("ReplicatedStorage")
local runservice = game:GetService("RunService")

local wallclimb = require(RS.WallClimb)

RS:WaitForChild("Climb").OnServerInvoke = function(plr, identifier, identifier2)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local HRP = char.PrimaryPart
	local hum = char:WaitForChild("Humanoid")
	if identifier == "Touch" then
		hum.AutoRotate = false
		return true
	elseif identifier == "Move"  and identifier2 ~= "Nil" then
	elseif identifier == "Stop" then

I changed a bit of it.

Can you also share the error you are getting?

In the output i’m getting: Unable to assign property VectorVelocity. Vector3 expected, got nil

are you sure the error its because of the remote function?, can you tell me in which script is the error and on what line?

On the client 44 where climb is being invoked to the server with the parameters “Move” and control.

elseif identifier == "Move"  and identifier2 ~= nil then

Nevermind I did have to use if statements, I removed the error by doing this.

1 Like

Ill send the message i was writing anyways:
Alright, so here the error isnt on the remotefunction, the first mistake ive notice, is on the conditional “if”, this conditional works like this: if true or true or true, so the correct way of using it would be this; if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.D then

also how you are accesing the table seems like an incorrect way. You can try this:

	local controlstable = {
		[Enum.KeyCode.W] = HRP.CFrame.LookVector * 16,  -- Assuming forward direction
		[Enum.KeyCode.S] = HRP.CFrame.LookVector * -16, -- Assuming backward direction
		[Enum.KeyCode.A] = HRP.CFrame.RightVector * -16, -- Assuming left direction
		[Enum.KeyCode.D] = HRP.CFrame.RightVector * 16,  -- Assuming right direction
	local control = controlstable[input.KeyCode]
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.