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

Output says "Argument 1 missing or nil" when trying to fire client event?

I'm trying to make a script that will fire the client on a remote event when you click a textbutton of a surfacegui to make a localscript run. When I try to click the texbutton, the only thing the output gives is "Argument 1 missing or nil" and nothing else. I've tried for hours putting things in different locations but nothing has worked. Here is the script:

local ReplicatedStorage = game.ReplicatedStorage
local Button = game.Workspace.GUI.SurfaceGui.SoundID

function clicked(player)
	ReplicatedStorage.ShowGUI:FireClient()
end

Button.MouseButton1Click:Connect(clicked)

Any help is appreciated!

1 answer

FireClient() needs 1-2 arguments.

First: The player to fire to. In this case, it's "player", on line 1.

Second: Any other arguments you want to send, but argument #2 is not necessary in all cases. In your case, we don't need any other data, so we leave argument #2 empty, because you just need to show a GUI.

The error "Argument #1 missing or nil" means that you haven't supplied any player to fire to.

Try this:

game.Players.PlayerAdded:Connect(function(player)

local ReplicatedStorage = game.ReplicatedStorage
local Button = game.Workspace.GUI.SurfaceGui.SoundID

local function clicked()
	ReplicatedStorage.ShowGUI:FireClient(player)
end

Button.MouseButton1Click:Connect(clicked)
end)

Hope this helped!

5 comments

0

I just adding that stuff to the script and now I got a new error. The output now says "FireClient: player argument must be a Player object  -  Server  -  Click:5"

0

oh it does?

0

i will update the script

0

ok try with this updated script

0

Now it works! Thanks for your help!

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