Unable to cast value to object

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?

Because LocalScripts cannot run in the workspace unless they are parented to a player’s chatacter. Move it to StarterPlayerScripts

1 Like

I’m so embarrassed #30charrrrrr