Unable To cast Value To Object on Camera

hey! im getting an issue where i try to pass the players camera through a function to a module but it doesn’t seem to go through. I keep getting this error:

" 21:15:28.349 Unable to cast value to Object - Client - openModule:15"

Lines of Error:

local cameraTween = tweenService:Create(camera, twi, {FieldOfView = inFov})

and

openModule.openShop(frame, currentCamera, normalSize)

– client

openEvent.OnClientEvent:Connect(function()
	if isDebounced then return end
	
	isDebounced = true

	local currentCamera = workspace.Camera

	if currentCamera then
		openModule.openShop(frame, currentCamera, normalSize)
	else
		warn("CurrentCamera is nil")
	end

	wait(0.5)
	isDebounced = false
end)

– module

function openNpcShop:openShop(frame, camera, openSize)
	local openSizeTween = tweenService:Create(frame, frameTwi, {Size = openSize})
	local cameraTween = tweenService:Create(camera, twi, {FieldOfView = inFov})

	frame.Visible  = true

	openSizeTween:Play()
	cameraTween:Play()

	shopBlur.Enabled = true
end

any help is appreciated!!

I believe it’s this line that’s causing the issue. The Camera and CurrentCamera objects are 2 separate things. Try editing this line to:

local currentCamera = workspace.CurrentCamera

They aren’t, the CurrentCamera references which camera is being used so CurrentCamera = Camera.

Why must the camera be passed through the function if this is a local module? You can just directly reference the Camera from within the module itself.

ive found the solution. i should of used a colon for

openModule.openShop(frame, currentCamera, normalSize)

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