Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Something is wrong with "FireClient"?

The error states that plr must be an object, even though when I print out the player before firing, it says my username. Why is this happening and how can I fix this? P.S. The if statement is inside of a modulescript function and fires every 1 second in a while true do loop.

	if seat:FindFirstChild("SeatWeld") and seat.SeatWeld.Part1.Parent.ClassName == "Model" then
		plr = game.Players:GetPlayerFromCharacter(seat.SeatWeld.Part1.Parent)
		print(plr)
		Sitting = true
		SitEvent:FireClient(plr,Sitting,seat) -- here
	else
		Sitting = nil
		SitEvent:FireClient(plr,Sitting,seat)
	end

4 comments

0

What line are you getting the issue on?

0

On line 3, try print(type(plr)) and let me know what it prints.

0

The script may be jumping to "else," and based on this code, you never provided a definition for 'plr' in this if statement route. I would need to see more context in order to make this an accurate judgement. Does it actually error on line 5?

0

^

1 answer

✓ Accepted answer

Servers and Clients

If you are using a server script to :FireClient() and using a server script to use .OnClientEvent, it will not work.

You need to FireClient from servers, and receive ClientEvents from the Client.

Hope this helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.