Problem with scope in local script

How do I transfer the information of the character and camera variables being changed to the rest of the script?

The script:

local plr = game.Players.LocalPlayer
local plrCamera = game.Workspace.CurrentCamera

local remoteEvents = game.ReplicatedStorage.RemoteEvents
local cameraEvent = remoteEvents.CameraInitialize

plrCamera.CameraType = Enum.CameraType.Scriptable

local character = nil
local camera = nil

local intial = cameraEvent.OnClientEvent:Connect(function(playerPart, cameraPart)
	if not playerPart or not cameraPart then
		cameraEvent:FireServer(plr)
	else
		plrCamera.CFrame = cameraPart.CFrame
		character = playerPart
		camera = cameraPart
	end
end)

print(character)
print(camera)
1 Like

It currently is being transferred to those variables, you would just need to wait until the event is called for the printed variables to hold the new values.

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