Problem with remote event arguments

Hi there. I am a novice developer trying to make a game with ball physics, and make the camera follow the ball. I have some issues with a few remote events that are required to avail the camera.

Server script:

local rs = game:GetService("ReplicatedStorage")
local ballevent = rs.BallEvent

script.Parent.MouseClick:Connect(function(player)
	local ball = game.ServerStorage.Ball:Clone()
	ball.Parent = workspace
	ballevent:FireClient(player,ball)
end)

Client script:

local rs = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

rs.BallEvent.OnClientEvent:Connect(function(ball)
	cam.CameraSubject = ball
end)

I really don’t know why, but the last time I was debugging it displayed the ball as a nil index, while also being specified in the arguments of the server script.

Client can’t access server storage. Place it in replicated storage instead.

1 Like

Don’t pass the Instance along the RemoteEvent. Try sending a different thing the ball can be identified by - maybe a name.

1 Like

The ball is placed inside workspace not server storage. The issue is related to the small time needed for the object to replicate to the client. I have already addressed it in another topic:

2 Likes

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