How do I access the camera in a server script using remote events

I am trying to make it so that when a player click their mouse my remote event prints the name of the camera’s parent.

This cannot be done using a server script so I am trying to fire the server and pass on information and it isn’t working.

Local script:

local mouse = game.Players.LocalPlayer:GetMouse()
local camera = game.Workspace.Camera
mouse.Button1Down:Connect(function()
	script.Parent.MouseInfoRE:FireServer(camera)
end)

Server script:

script.Parent.MouseInfoRE.OnServerEvent:Connect(function(player, camera)
	print(camera.Parent)
end)

is there any errors when you run the script?

Output:

Players.PrinceGold86.PlayerGui.GrenadeThrowMission.GrenadeHandler:18: attempt to index nil with 'Parent' 

This means that camera wasn’t returned, it was nil, can you try and make it print the camera without the .Parent?

also may i ask where the RemoteEvent is?

1 Like

image

Can you put it into ReplicatedStorage, Remote events are mainly used within that area, workspace or a tool

In order for both the server and clients to utilize a remote event, the RemoteEvent object itself must be in a place where both sides can see it. As such, we recommend that you store the RemoteEvent inside of ReplicatedStorage , although in some cases it’s appropriate to store it in the workspace or inside a Tool . ~ Developer hub’s description

If your “grenadeThrowMission” instance is within something such as StarterPlayerScripts then the server won’t see that, only the player

1 Like

yes and thanks for the help ive been working on this for 3 days and finally found a solution