Malfunctioning RemoteEvent

I have a remote event that seems to be failing to pass values. While most remote events pass their values correctly, this one, in particular, seems to pass nothing but nil. I run a print right before the sender (a server script) fires the event, so I know the sender is passing the values right to the event. the print right after the event in the receiver, however, always gives all nils.

Sender (Server Script)

event = game.ReplicatedStorage.PreviewRequest

event.OnServerEvent:Connect(function(player, source, item)
	print("Fired")
	--local gui = player.PlayerGui.InventoryGui.Frame.DescriptionFrame.WorkingViewportFrame
	if item == "Campfire Kit" or item == "Heater Kit" then
		item = game.ServerStorage.Entities[string.sub(item, 1, -4)]
	else
		item = game.ServerStorage[item]
	end
	item = item:Clone()
	print(player, source, item)
	event:FireClient(player, source, item)
end)

Receiver Script (Local Script)

TweenService = game:GetService("TweenService")
RunService = game:GetService("RunService")
counter = 0
event = game.ReplicatedStorage.PreviewRequest

event.OnClientEvent:Connect(function(source, object)
    print(source, object)
    item = object
end)

camera = Instance.new("Camera")
camera.Parent = script.Parent
camera.CFrame = CFrame.new(Vector3.new(-5, 2, 5), item.Position)
script.Parent.CurrentCamera = camera
local radius = 5
local center = item.Position
local rad, cos, sin = math.rad, math.cos, math.sin
local totalTime = 50
while true do
    counter = counter + 1
    camera.CFrame = CFrame.new(Vector3.new(center.X + radius*cos(rad(counter%1440)), 2, center.Z + 
    radius*sin(rad(counter%1440))), Vector3.new())
    RunService["Heartbeat"]:Wait()
end

Relevant console output

TeamTabyGamez nil Apple (Server)
nil nil (Client)

1 Like

You are passing a reference to an instance which exists in ServerStorage. This does not exist on the client, therefore it is nil. You can place it in ReplicatedStorage where the client has access to. Objects are not sent over the client/server boundary, only their reference iirc.

3 Likes

Thanks! Just had to reparent the object and it worked. For some reason, my brain didn’t register that. Maybe after working for about 14+ hours, I should head to bed.

2 Likes