Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Argument 1 is missing or nil, why that happend??

Asked by 4 years ago
Edited 4 years ago

Hello, im trying to make change player camera position with RemoteEvent but its still giving me error Argument 1 is missing or nil and i cant find the problem by myself, i tried to search on this site but didnt found anything.

Localscript:

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

local player = Players.LocalPlayer
local camchng = ReplicatedStorage:WaitForChild("Change")
local camm = workspace.CurrentCamera


local function changeFired(player, Cactus)
    local first = workspace.People:WaitForChild(Cactus)
    local two = first.main
    camm.CameraSubject = two
end

camchng.OnClientEvent:Connect(changeFired)

Script:

game.Players.PlayerAdded:Connect(function(boomer) 
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local camerachange = ReplicatedStorage:WaitForChild("Change")
    local get = game:GetService("ServerStorage")
    local d = math.random(1, 1)
    if d == 1 then
    if workspace.Busies.Busy1.Value == false then
        workspace.Busies.Busy1.Value = true
    wait(5)
    get.Cac1:Clone().Parent = workspace.People
    local aeugh = workspace.People.Cac1
    camerachange:FireClient(boomer, aeugh)


end
end
end)

would be happy if you point at my problem:)

0
That just means you havent filled out the second argument, either that or we havent seen the full script SoftlockedUnderZero 668 — 4y
0
Here the whole scripts Nermis2017 -4 — 4y
0
Which line is the error on? Filipalla 504 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The problem is that when you Fire a Remote Event/Function from server to client, the first argument on the server is player, but not on the client.

For example:

-- server script
RemoteEvent:FireClient(playerInstance, arg1);

-- localscript
RemoteEvent.OnClientEvent:Connect(function(arg1)
  print(arg1);
 -- The player from the serverscript is not the first argument here. The player parameter is "ignored", for lack of better terms.
end)

To fix your script, remove Player from the localscript and have the first argument be Cactus only.

0
This is the correct answer Filipalla 504 — 4y
0
Thanx its worked!)) Nermis2017 -4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

OnClientEvent doesn't pass the client Player because that's always the LocalPlayer. player is Cactus and Cactus is nil.

aeugh is a reference to an instance so once you do have Cactus fixed, you'll have a problem trying to pass it to WaitForChild, because that takes the string name of the instance. (Cactus.Name)

Cactus will already be a reference to the thing you're trying to look up, so you can just use that instead of making the first variable.

Answer this question