Argument 1 missing or nil

So I’m trying to make a takedown thing and I’m trying to use camera manipulation with remote events but I keep getting the error: “Argument 1 missing or nil” Why am I getting this error?

Here is the Hitbox script I have (Script)

local hitbox = script.Parent
local knife = game.StarterPack:FindFirstChild("Knife")

local db = true

hitbox.Touched:Connect(function(hit)
	local char = hit.Parent
	local hum = char:FindFirstChild("Humanoid")
	local plr = game.Players:FindFirstChild(char.Name)

	if db and hum and plr then
		db = false
		local KTF = plr:WaitForChild("KTF")
		local KT = KTF:FindFirstChild("Takedown")
	 
		if KT.Value then
			game.ReplicatedStorage.TakedownCam:FireClient()
			script.Parent.Parent.Humanoid.Health = 10
		else
			print("Takedown is not available at the moment")
		end
		
		wait()
		db = true
	end
end) 

Here is the RemoteEvent Script (LocalScript)

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local TakedownCam = game.Workspace.TakedownCam

game.ReplicatedStorage.TakedownCam.OnClientEvent:Connect(function()
	repeat wait()
		cam.CameraType = Enum.CameraType.Scriptable
	until cam.CameraType == Enum.CameraType.Scriptable
	cam.CFrame = TakedownCam.CFrame
end)

You’re supposed to give it the player argument.

Do I use my variable plr or put Player

As @Pokemoncraft5290 said, you need to give the player argument, or if you want to fire all the players you need to use :FireAllClients()

I just want it to fire for the person that is doing the takedown

You need to use your plr variable because it stores the player that touched the part.

Everything works normal but the camera dosent change I have the code as this

game.ReplicatedStorage.TakedownCam:FireClient(plr)

Any errors in the output? Maybe that could help us to debug your code.

No errors
https://gyazo.com/eaad825832477796b8c421254ff2cbf2

Even if I try this the camera dosent change

Where is your Local Script located at? Is it in the starter gui?

So my local script is this

LocalScript located in ServerScriptService

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local TakedownCam = game.Workspace.TakedownCam

game.ReplicatedStorage.TakedownCam.OnClientEvent:Connect(function()
	repeat wait()
		cam.CameraType = Enum.CameraType.Scriptable
	until cam.CameraType == Enum.CameraType.Scriptable
	cam.CFrame = TakedownCam.CFrame
end)

I fixed it thanks, put it in starterGUi

1 Like

ServerScriptService is a service for the server. Local Scripts won’t execute if they are parented to the ServerScriptService.
Try putting your script in the StarterGui or StarterPlayerScripts.