FireClient Not Working

So here, I’ve been trying to make it so the CameraSubject of CurrentCamera becomes LocalPlayer’s head when the character sits on a specific seat that plays an animation. The animation works, however it doesn’t seem like the remote event is not being fired.

Seat Script (ServerScript):

local seat = script.Parent;
local pov = game.ReplicatedStorage.POV;
local char;

function added(child)
	if (child.className=="Weld") then
		local human = seat.Occupant;
		if human ~= nil then
			anim = human:LoadAnimation(seat.sitanim);
			anim.Looped = true;
			anim:Play();
			seat.Transparency = 1;
			char = human;
			pov:FireClient(game.Players:GetPlayerFromCharacter(char), true);
		end;
	end;
end;

function removed(child2)
	if anim ~= nil then
		anim:Stop();
		anim:Remove();
		seat.Transparency = 0.3;
		pov:FireClient(game.Players:GetPlayerFromCharacter(char), false);
	end;
end;

seat.ChildAdded:connect(added);
seat.ChildRemoved:connect(removed);

LocalScript (in Backpack):

local char = player.Character or player.CharacterAdded:Wait();
local head = char:WaitForChild'Head';

local camera = workspace.CurrentCamera;
local remoteevent = game.ReplicatedStorage.POV;
local scream = false;
local runs = game:GetService'RunService';

runs.RenderStepped:Connect(function()
	if (scream == true) then
		camera.CameraType = Enum.CameraType.Scriptable;
		camera.CFrame = CFrame.new(head.CFrame.Position, head.CFrame.Position + head.CFrame.lookVector)
	elseif (scream == false) then
		camera.CameraType = Enum.CameraType.Custom;
		camera.CameraSubject = char:WaitForChild'Humanoid';
	end;
end);

remoteevent.OnClientEvent:Connect(function(plr, activation)
	if (activation == true) then
		scream = true;
		print'true!';
	else
		scream = false;
		print'false!';
	end;
end);

I put the print in order to see if the scripts work properly. Nothing was printed, and the camera’s subject was consistently being set to Humanoid, which meant that ‘scream’ was still false. I didn’t get any errors. Can someone tell me a possible solution?

1 Like

FireClient requires the Player as the First Argument, then your Arguments, which would look like this:

FireClient(Player, Argument1, Argument2)

And within your Code, Argument 1 is plr, OnClientEvent does not have a Player argument like OnServerEvent, so you should only need the activation Argument.

Thank you for helping me out and giving me a better understanding about it. But now, it gives me an error that the player argument must be a player object. Any ideas on that though?

It means the Argument you Provided for the Player is not Correct, and it should be a Player Instance, you hsould check if the Object you’re checking is returning the Player or not, because GetPlayerFromCharacter does not gaurantee a Player.

My bad. Didn’t see that I was referring to the humanoid and not the character with ‘char’. Thanks for the help!

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