'Argument 2 missing or nil' when firing RemoteEvent

I’m trying to make a script that can run on the server to tell all clients to move their camera to a given CFrame with the given TweenInfo. However, when the code is run, it throws the error ‘Argument 2 missing or nil’.

Here is the script on the server:

CameraCFrame = CFrame.lookAt(script.Parent.CameraPoint.CFrame.Position,script.Parent.Back.CFrame.Position)
TI = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
game.ReplicatedStorage.CameraControl:FireAllClients("TweenCamera",TI,CameraCFrame)

And here is the LocalScript:

TS = game:GetService("TweenService")
camera = workspace.CurrentCamera
game.ReplicatedStorage.CameraControl.OnClientEvent:Connect(function(p1,p2,p3,p4)
	if p1 == "TweenCamera" then
		camera.CameraType = Enum.CameraType.Scriptable
		TS:Create(camera,p2,{CFrame=p3}):Play()
	end	
end)

I’m probably just being stupid here, but if anyone can help me I would definitely appreciate it!

You can’t actually send clients TweenInfo, you’ll have to send them a table with all the info instead and create the TweenInfo on the client. And please start your variables with “local”

– SERVER –

local CameraCFrame = CFrame.lookAt(script.Parent.CameraPoint.CFrame.Position,script.Parent.Back.CFrame.Position)
local TI = {1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut}
game.ReplicatedStorage.CameraControl:FireAllClients("TweenCamera",TI,CameraCFrame)

– CLIENT–

local TS = game:GetService("TweenService")
local camera = workspace.CurrentCamera
game.ReplicatedStorage.CameraControl.OnClientEvent:Connect(function(p1,p2,p3,p4)
	if p1 == "TweenCamera" then
		camera.CameraType = Enum.CameraType.Scriptable
		TS:Create(camera,TweenInfo.new(unpack(p2)),{CFrame=p3}):Play()
	end	
end)
1 Like

Thanks for the fast response! I’ll try this out.

This code worked! Thank you a lot

1 Like

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