so I made this script that when you touch a part it fires a client event to another script
script that fires the event:
v.ss.Touched:Connect(function(plr) local w = v:WaitForChild("ww") game.workspace.CurrentCamera.CFrame = camra2.CFrame game.workspace.CurrentCamera.CameraType = "Scriptable" s1:FireClient(plr,w) end)
local script that makes the function when the event is fired:
s1.OnClientEvent:connect(function(plr,w) print(":>") game.Players.LocalPlayer.Character.Humanoid:MoveTo(w.Position) end)
why does it say that w is a nil value?
btw there are local things that I haven't added since it's not necessary and has nothing to do with the initial question.
Firstly on a side note, you can't access the CurrentCamera from a server script, only from a local script, so you will have to move that.
As for why w is a nil value, when you use FireClient from the server, you must enter the player argument as you have done to identify which player's client you want to fire the event on. However, on receiving the event in the local script, the player is not given as an argument, as you do not need it to identify the player. Because of this, the "w" variable is actually the variable you define as plr in the local script, and the variable defined as w is nil. So to fix this, remove the plr variable as an argument in the local script and only have w instead.
sl.OnClientEvent:Connect(function(w)
instead of
sl.OnClientEvent:Connect(function(plr,w)