Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Must be a player object?

Asked by 2 years ago
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

0
hmmm xxaxxaz 42 — 2y
0
idk, make sure that the object is a player. not just a humanoid. xxaxxaz 42 — 2y
0
got the answer fireclient must have a player argument so it is send to the player MiAiHsIs1226 189 — 2y
0
game.ReplicatedStorage.ShowExitCar:FireClient(game.Players:FindFirstChild(hit.Parent.Name)) greatneil80 2647 — 2y

3 answers

Log in to vote
2
Answered by
DrShockz 233 Moderation Voter
2 years ago
Edited 2 years ago

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

0
when you discover headers in scriptinghelpers, also good answer i like Xapelize 2658 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

https://scriptinghelpers.org/questions/124217/how-can-i-make-a-view-model-to-be-visible-when-i-use-the-tool

0
idk sonichfan 62 — 2y
0
answers are not advertisements xxaxxaz 42 — 2y
0
LOOOOOOOOOOOOOOL I CANT greatneil80 2647 — 2y
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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

Answer this question