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.
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: