Unable to cast value to object

As I said before, :Interpolate() is deprecated and although this does not mean that it’s the cause why it doesn’t work, you shouldn’t be using it anyway as it’s bad practice, use TweenService.

Example:

--Assuming there's a reference to TweenService

local cam = game.Workspace.Camera

TweenService:Create(cam, TweenInfo.new(5), {CFrame = FinalCFrame}):Play()

Where FinalCFrame is a CFrame resulting from the interpolation of Position and Focus which you can obtain using :Lerp()

I know I listened to your advice and I will delete the interpolate() though that’s is not the issue the issue is that the client event won’t fire up Idk why

local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local CameraIn = game.ReplicatedStorage.CameraIn
local PlayerCamera = game.ReplicatedStorage.PlayerCamera

local function shake() local camera = game.Workspace.CurrentCamera for i = 1,10 do wait() 
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,2,0) wait() 
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,-2,0) end end

CameraIn.OnClientEvent:Connect(function(plr,Position,Focus,Time)
	print(1)
	
			local cam = game.Workspace.CurrentCamera
	        cam.CameraType = Enum.CameraType.Scriptable
	     local tween = TweenService:Create(cam, TweenInfo.new(5), {CFrame = Position}):Play()
	        print(4)
             shake()
	        script.Sound:Play()
			
end)


PlayerCamera.OnClientEvent:Connect(function()
	local camera = game.Workspace.CurrentCamera
	script.Sound:Stop()
	camera.CameraType = Enum.CameraType.Custom

end)

could you give more information about the code - does this code work?

As I mentioned before the Client event won’t fire and there’s no error sent

you should try using the EZ Camera system which is a port from unity and probably will work better for your use

I wish the camera shake was the issue but I can’t even find out why the event doesn’t fire up…

You think that the event isn’t firing, but it is. You are listening to a different event than the one that is fired.

See @vicy98’s reply

check your server side script then

I did & I fixed it server side looks perfect to me it even prints variable that is after the :FireClient event

local played = false
local CameraIn = game.ReplicatedStorage.CameraIn

script.Parent.T.Touched:Connect(function(v)
	if v.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(v.Parent)
		if played == false then
			played = true
			print(3)
			CameraIn:FireClient(plr, workspace.CameraPosition.CFrame, workspace.CameraAim.CFrame, 5)
			print(1)
			wait(1)
			played = false
			v.Parent.Humanoid.Health = 0
		end
	end
end)

image

I might just saw the issue because it’s not interpolation anymore mb

Looking closely to your code you made a mistake with the parameters.

You are declaring the plr variable and although it’s a parameter of :FireClient(), it is not forwarded to the player, so plr is assuming the value of

But if I remove the plr it’ll again assume the cframe is the player, won’t it?
on the server side parameter

No, you only need to pass the plr object in the FireClient() call, roblox’s engine will not pass the plr argument to the client

1 Like

Alright so I did

CameraIn.OnClientEvent:Connect(function(Position,Time)
	print(1)
	
		local cam = game.Workspace.CurrentCamera
	       cam.CameraType = Enum.CameraType.Scriptable
	     local tween = TweenService:Create(cam, TweenInfo.new(5), {CFrame = Position}):Play()
	        print(4)
             shake()
	        script.Sound:Play()
			
end)

Still does nothing and even if it would I should’ve seen client sided reaction?

local FinalCFrame = Position:Lerp(Focus, 0.2) --adjust 0.2 as you please

To further understand how lerping works, I suggest reading this post.

Again… I wish it would’ve been the problem but it isn’t and I’ll say it again anyways the issue is that the client event won’t fire up
image
^^ It’s in fact does not print 1 when fired from the server


Server side fire event function^^

image
Should’ve printed the 1 from the client side

That is impossible if the event is correctly referenced. I am starting to wonder…is the LocalScript located in a place where it can run? Does it run in the first place?

Well it’s located in a model in the workspace does it matter?