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

Must be a player object?

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Humanoid then
		game.ReplicatedStorage.ShowExitCar:FireClient()
	end
end)

it says fire client: player argument must be a player object

4 comments

0

hmmm

0

idk, make sure that the object is a player. not just a humanoid.

0

got the answer fireclient must have a player argument so it is send to the player

0

game.ReplicatedStorage.ShowExitCar:FireClient(game.Players:FindFirstChild(hit.Parent.Name))

3 answers

✓ Accepted answer

Hello,
It seems as if you've incorrectly used the :FireClient() event!

No worries though as I'll teach you today how to use the :FireClient() event!

FireClient

Below is an example of how to send an argument to a specific client using a RemoteEvent in a Server Script (See below why.)

Why only in a ServerScript? The reason we can only have the FireClient event on Server Scripts is to protect a games security as a hacker can easily intercept Local Scripts, and a player could use FireClient to, for example give themselves a very over powered weapon in an FPS for example.

####See the RemoteEvent:FireClient Documenation for a greater understanding.

Below I put an example of what your script should look like!

local ExitCar = game.ReplicatedStorage.ShowExitCar

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Humanoid then
		local player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
		ExitCar:FireClient(player, true)
	end
end)

Let's look at the important lines of the code above!
local player = game.Players:GetPlayerFromCharacter(Humanoid.Parent) ExitCar:FireClient(player, true)

As you can see I grab the player instance that we are going to Fire the event to by using the :GetPlayerFromCharacter function!

I then fire the event to client by doing ExitCar:FireClient(player, true) The true depends on what the arguments are in your LocalScript, but in this example I use to to signify that the player exits the vehicle is equal to true!

I hope I could help you today and help with your understanding of the :FireClient() event!
If I wasn't able to solve your issue feel free to contact me on Discord: DrShockz#0246

Thanks for reading, DrShockz

1 comment

0

when you discover headers in scriptinghelpers, also good answer i like

FireClient ( Player argument) FireAllClients ( tuple) FireServer( tuple ) OnServerEvent(Player argment, tuple) OnClientEvent( tuple )

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