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

Arugment 1 missing or nil????DESCRIBE

Hello, I have a script for a car GUI to appear. Except I get Arugment 1 missing or nil? What does that mean???

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") or ("Mesh")then
    game.ReplicatedStorage.Right:FireClient()
end
end)

2 comments

0

You have to put in a player object for FireClient!

0

??????

2 answers

("Mesh") means nothing
you have to write hit.Parent:FindFirstChild("Mesh")

Edit :

Put an argument inside :FireClient() which is the player

If you want to fire it on all player, use :FireAllClients()

11 comments

0

wrong question bro

0

Uhh What?

0

What? It's line 3 where the error is on. Mesh is the car's wheels.

0

You need to put the player in fireClient argument ':FireClient(player)' also what i said is valid , ("Mesh") is not anything, you are trying to create an argument with no function

0

Ignoring second part, I get unknown global Player.

0

@squidiskool You need to put an actual player in the argument, that happen because the player doesnt exist

0

How do I define it?

0

You can just do game.ReplicatedStorage.Right:FireClient(game.Players:FindFirstChild(hit.Parent.Name))

0

I now get FireClient: player argument must be a Player object. Really helping here?

0

????????? What did you type in e.e?

0

All you gotta do is put an actual player in the argument, it could be the player that triggers the .Touched, you can't fire a client event without specifying who the client is, unless you decided to :FireAllClient()

FireClient() takes a player as the first argument. That is a REQUIREMENT, or else the server won't know which client it is supposed to be firing to.

You don't want to use the same code block for meshes and the humanoid because otherwise you will sometimes get nil for the player object and it will throw an error.

"Mesh" will always evaluate to true because it is not false or nil so your logic is incorrect, If you are checking if it is a mesh, use Instance:IsA(). If you are checking for something called "Mesh" in hit.Parent, use FindFirstChild a second time. If you are checking for a mesh named anything in hit.Parent, use FindFirstChildOfClass

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildOfClass("VehicleSeat") then
		local char = hit.Parent.Seat.Occupant.Parent
		if char then
	    	game.ReplicatedStorage.Right:FireClient(Players:GetPlayerFromCharacter(hit.Parent))
end
	end
end)

19 comments

0

What would I put in Do stuff on the mesh here.? The car's wheels contain a Mesh, so it needs to check if there is a mesh.

0

Why are you checking for car wheels in the first place? I am unsure what your use-case is.

0

So what I want is that when the car's wheels touch the trigger, it should fire a remoteevent enabling a direction gui.

0

It doesn't seem like the player ever touches the trigger themselves. In what instance could hit.Parent be the player?

0

The player is levitating because they are in the car. But I don't get what you mean?

0

If they are in the car, then they will never touch the trigger and therefore you cannot do anything with them. Is there a "Seat" instance inside the car that the player sits on?

0

Yeah, but that is levitating too.

0

That's fine, I will change the code so you can find if there is a player sitting.

0

Ok, did you change It yeyeyeyyttt

0

Ok, did you change It yeyeyeyyttt

0

The new code will check for a seat in the car, and if the seat is occupied, get the character from the person occupying the seat, Then you can fireclient knowing that there will always be a player.

0

Help I get unknown global Players.

0

You should be defining Players somewhere in your code as game:GetService("Players")... You can also use game.Players instead of Players.

0

I used the code but it doesn't seem to detect the car, nothing happens.

0

Also it's a VehicleSeat, and the name is DriveSeat.

0

then change IsA("Seat") to IsA("VehicleSeat"). All seats have the .Occupant property so it should still work the same. The name doesn't matter, IsA() is checking for the type of the object, not the name.

0

Huh? IsA() doesn't show up in the code.

0

Oh right I forgot I took that out LOL. I changed it to FindFirstChildOfClass.

0

Hey, you still online? It is still not appearing.

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