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

Arugment 1 missing or nil????DESCRIBE

Asked by 3 years ago

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)

0
You have to put in a player object for FireClient! fluffyoreos32 63 — 3y
0
?????? squidiskool 208 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
("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()

0
wrong question bro virushunter9 943 — 3y
0
Uhh What? Azure_Kite 885 — 3y
0
What? It's line 3 where the error is on. Mesh is the car's wheels. squidiskool 208 — 3y
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 Azure_Kite 885 — 3y
View all comments (7 more)
0
Ignoring second part, I get unknown global Player. squidiskool 208 — 3y
0
@squidiskool You need to put an actual player in the argument, that happen because the player doesnt exist Azure_Kite 885 — 3y
0
How do I define it? squidiskool 208 — 3y
0
You can just do game.ReplicatedStorage.Right:FireClient(game.Players:FindFirstChild(hit.Parent.Name)) Azure_Kite 885 — 3y
0
I now get FireClient: player argument must be a Player object. Really helping here? squidiskool 208 — 3y
0
????????? What did you type in e.e? Azure_Kite 885 — 3y
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() Azure_Kite 885 — 3y
Ad
Log in to vote
0
Answered by
Sparks 534 Moderation Voter
3 years ago
Edited 3 years ago

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)

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. squidiskool 208 — 3y
0
Why are you checking for car wheels in the first place? I am unsure what your use-case is. Sparks 534 — 3y
0
So what I want is that when the car's wheels touch the trigger, it should fire a remoteevent enabling a direction gui. squidiskool 208 — 3y
0
It doesn't seem like the player ever touches the trigger themselves. In what instance could hit.Parent be the player? Sparks 534 — 3y
View all comments (15 more)
0
The player is levitating because they are in the car. But I don't get what you mean? squidiskool 208 — 3y
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? Sparks 534 — 3y
0
Yeah, but that is levitating too. squidiskool 208 — 3y
0
That's fine, I will change the code so you can find if there is a player sitting. Sparks 534 — 3y
0
Ok, did you change It yeyeyeyyttt squidiskool 208 — 3y
0
Ok, did you change It yeyeyeyyttt squidiskool 208 — 3y
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. Sparks 534 — 3y
0
Help I get unknown global Players. squidiskool 208 — 3y
0
You should be defining Players somewhere in your code as game:GetService("Players")... You can also use game.Players instead of Players. Sparks 534 — 3y
0
I used the code but it doesn't seem to detect the car, nothing happens. squidiskool 208 — 3y
0
Also it's a VehicleSeat, and the name is DriveSeat. squidiskool 208 — 3y
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. Sparks 534 — 3y
0
Huh? IsA() doesn't show up in the code. squidiskool 208 — 3y
0
Oh right I forgot I took that out LOL. I changed it to FindFirstChildOfClass. Sparks 534 — 3y
0
Hey, you still online? It is still not appearing. squidiskool 208 — 3y

Answer this question