Attempt to call a nil value with OnClientEvent

Well, for some reason it gives me the error of attempt to call a nil value, I have no idea why it gives it to me. Well well, I am trying to receive data with OnClientEvent after sending 3 FireClient containing data. However, when “receiving them” it gives me an error. Before this did not happen, I do not know what the problem is

The server script that sends the three FireClient:

local Players = game:GetService("Players")
local TweenService=game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")

local InventoryRemote = ReplicatedStorage:WaitForChild("InventoryFunctions")

local ToolsFolder = ServerStorage:WaitForChild("Tools")

local Part_base = script.Parent:WaitForChild("base")

local Proximity = script.Parent:WaitForChild("Proximity"):WaitForChild("Interacción_fisica")

local Enabled = false
local Finish = false

Proximity.Triggered:Connect(function(player)
	local Position_base = Part_base.CFrame;
	local character = workspace:FindFirstChild(player.Name)
	--if character then local Get_tool = character:FindFirstChildWhichIsA("Tool") if not Get_tool or Enabled == true then return end
	Enabled = not Enabled
	if Enabled == false then
		--if Get_tool.Name == "Pan" then

			--[[Get_tool.Parent = Part_base;
			Get_tool.Handle.Anchored = true;
			Get_tool.Handle.CFrame = CFrame.new(Position_base.X - 0.6, Position_base.Y*1.45, Position_base.Z + 1.3) * CFrame.Angles(math.rad(0), 0, 1.94)]]


		InventoryRemote:FireClient(player, "Mouse_block", false, nil); 
		InventoryRemote:FireClient(player, "Block_activated_functions", false, nil)
		InventoryRemote:FireClient(player, "Move_camera", false, CFrame.new(Position_base.X - 0.3, Position_base.Y*3, Position_base.Z) * CFrame.Angles(math.rad(-90), 0, -14.135))
	else
		InventoryRemote:FireClient(player, "Mouse_block", true, nil); 
		InventoryRemote:FireClient(player, "Block_activated_functions", true, nil)
		InventoryRemote:FireClient(player, "Move_camera", true, nil)
		
	end
	--end
	--end
end)

The OnClientEvent Receiver LocalScript:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local InventoryRemote = ReplicatedStorage:WaitForChild("InventoryFunctions")

local player = Players.LocalPlayer
local WaitCharacter =  player.Character or player.CharacterAdded:wait(2)

local PlayerGui = player:WaitForChild("PlayerGui")
local Menu_de_mapa = PlayerGui:WaitForChild("MenuDeMapa")

local camera  = require(script:WaitForChild("Mouse_block"))

camera:Enable()

player.CharacterAdded:Connect(function()
	camera:Disable()
	wait(0.5)
	camera:Enable()
end)
--OTS_CAMERA_SYSTEM:Disable()

InventoryRemote.OnClientEvent:Connect(function(Service, Bool, other)
if Service == "Mouse_block" then
		camera:Send(Bool)
	elseif Service == "Block_activated_functions" then
		camera:Enabled_or_disabled_click_detector(Bool)
	elseif Service == "Move_camera" then
		camera:Lock_or_unlock_camera_ubication(Bool, other)
	end
end)

If it’s not sensitive information, can you copy the error message and post it here?

I’m specifically looking for the line number, which function caused the error, and whether it was server side or client side.

Well, basically it is the error that is in the title, and the error is given to me in this part:

I can assume this is client-side since it’s in a local script.

That doesn’t make sense, that line would never error at runtime.

If you meant the line below, camera:Send(Bool), then it might be because the :Send method doesn’t exist on Camera. It corresponds with the error at least. Maybe you forgot to capitalize the first letter in the method definition?

1 Like

In fact, apparently it gave me the error in the part of the Bool, I do not understand why this happened.

InventoryRemote.OnClientEvent:Connect(function(Service, Bool, other)
	print(Service)
	print(Bool)
	print(other)
if Service == "Mouse_block" then
		camera:Send(Bool)--this part
	elseif Service == "Block_activated_functions" then
		camera:Enabled_or_disabled_click_detector(Bool)
	elseif Service == "Move_camera" then
		camera:Lock_or_unlock_camera_ubication(Bool, other)
	end
end)
1 Like

There we go. It’s pretty important to share the full error. If that’s the line with the error, it means that camera.Send is nil. Where is camera set up?

It is not a camera, it is a ModuleScript with the method of this publication

Right yeah that module doesn’t have a Send method. What are you trying to do on that line?

Sorry, Forget that I removed the function that was giving the error in the script, the function makes the mouse freely move