I'm sure this is a simple error on my part, but I'm making a cutscene and on a script located in ServerScriptService I will fire a client event like this:

game.Players.PlayerAdded:Connect(function(p)
	plr = p
end)
local current = 1
game.ReplicatedStorage.RE.Camera:FireClient(plr,current)

the current value is which camera to switch scenes too. then, on a local script I have this:

function camera_change(plr,current)
	if current == 1 then
			local cam = workspace.CurrentCamera
			local point = game.Workspace.cam1
			cam.CameraType = "Scriptable"
			cam.CoordinateFrame = point.CFrame
	end
end

game.ReplicatedStorage.RE.Camera.OnClientEvent:Connect(camera_change)

without the 'if' statement the script works fine, but it breaks when I add the 'if' statement :l please help me with this, becuase its very confusing..

3 comments

0

The problem is that you placed the code outside the PlayerAdded function. Place lines 4 and 5 from the server script inside the function.

0

Remove the plr parameter on camera_change and it will work.

0

Thanks incapaz, your solution worked!