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:)
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.
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.