RemoteEvent: Argument 1 missing or nil

  1. The main error I’m getting on this script is when firing a remote event to the client when trying to change the Camera’s properties.

(LOCAL SCRIPT) LOCATED IN StarterCharacterScripts V

local RepStorage = game:GetService("ReplicatedStorage")
local FactoryCameraEvent = RepStorage.FactoryCamera
local Camera = game:GetService("Workspace").CurrentCamera
local ChangeCameraEvent = RepStorage:WaitForChild("ChangeCameraEvent")
local Factories = game:GetService("Workspace").FactoryNodes
local Player = game:GetService("Players").LocalPlayer

RepStorage.ChangeCameraEvent.OnClientEvent:Connect(function()
    local FacNodes = Factories:GetChildren()
    for _, Node in FacNodes do
        local defaultFactory = Node:FindFirstChild("DefaultFactory")
        if defaultFactory and defaultFactory:FindFirstChild(tostring(Player.UserId)) then
            local CameraPart = Node:FindFirstChild("DefaultFactory").CameraPart
            if CameraPart then
                Camera.CameraType = Enum.CameraType.Scriptable
                Camera.FieldOfView = 28
                Camera.CFrame = CameraPart.CFrame
            end
        end
    end
end)

(SERVER SCRIPT) ServerScriptService V

local Players = game:GetService("Players")
local Factories = game:GetService("Workspace").FactoryNodes
local TouchedTeleporter = script.Parent
local RepStorage = game:GetService("ReplicatedStorage")

TouchedTeleporter.Touched:Connect(function(touched)
    if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
        local Player = Players:GetPlayerFromCharacter(touched.Parent)
        if Player then
            local FacNodes = Factories:GetChildren()
            for _, Node in FacNodes do
                local defaultFactory = Node:FindFirstChild("DefaultFactory")
                if defaultFactory and defaultFactory:FindFirstChild(tostring(Player.UserId)) then
                    local FacTeleporter = Node:FindFirstChild("DefaultFactory").ReplicatedTeleporter
                    local HumanoidRP = Player.Character:FindFirstChild("HumanoidRootPart")
                    if FacTeleporter then
                        if HumanoidRP then
                            RepStorage.ChangeCameraEvent:FireClient()
                            HumanoidRP.CFrame = FacTeleporter.CFrame
                        end
                    end
                end
            end
        end
    end
end)
  1. I’ve never used RemoteEvents before so I am not familiar with these errors.

:FireClient() requires a Player to be passed into the parentheses as a paremeter.

RepStorage.ChangeCameraEvent:FireClient(Player, ...) -- Will fire to the player.

For your .OnClientEvent event, you need to mention the parameter by default.

RepStorage.ChangeCameraEvent.OnClientEvent:Connect(function(player: Player, ...) -- "player" is required.
    -- Do cool stuff!
end)

If you’re confused as to what ... is, it’s just any other argument you want to pass in. You don’t need to type ...

1 Like

You’re right about everything except this. You don’t need to specify anything because that’s what’s getting passed so you can do whatever with it. It’s good to know that the first return thing is the player who fired the event though

2 Likes

I had a feeling it WASN’T needed, but I wanted to mention it anyway. Thank you for clarifying.

1 Like

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