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

(FilteringEnabled) "Argument 1 missing or nil" error?

I made a part that has a ClickDetector in it and when the part is being clicked I want it to clone it self to the player's who clicked it PlayerGui.ScreenGui.

But I get this error:

Argument 1 missing or nil
Stack Begin
Script 'Workspace.Part.Script', Line 2
Stack End

Script in game.Workspace.Part:

script.Parent.ClickDetector.MouseClick:connect(function()
	game.ReplicatedStorage.RemoteEvent:FireClient()--error line
end)

LocalScript in game.StarterGui.ScreenGui

game.ReplicatedStorage.RemoteEvent.OnClientEvent:connect(function(player)
	game.Workspace.Part:Clone().Parent=player.PlayerGui.ScreenGui
end)

I would appreciate if anybody could help me out.

2 answers

✓ Accepted answer

Your script on the server simply doesn't know what client to send its request to.

How to fix:

script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
    game.ReplicatedStorage.RemoteEvent:FireClient(playerWhoClicked)--error line
end)

1 comment

0

Thanks.

Just as the error states, you're missing an argument. FireClient requires you to specify which client, e.g.,

remote:FireClient(game.Players.Perci1)

If you want to fire the event for all clients, however, you can just use FireAllClients.

remote:FireAllClients()


There also seems to be a missunderstanding in your second script.

game.ReplicatedStorage.RemoteEvent.OnClientEvent:connect(function(player)
	game.Workspace.Part:Clone().Parent=player.PlayerGui.ScreenGui
end)

For OnClientEvent, there is no built in player parameter. That's for OnServerEvent. But since it's a local script, you can just use game.Players.LocalPlayer instead.

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