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

FireClients (need explanation please!) [?]

Hello! I've been very confused of this :FireClient(). I've tryed it myself, and this is the code:

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

After running and testing, I've got this error: Argument 1 missing or nil

Need explanations please! Thank you.

1 comment

0

I have answered, you may look below at the answers.

2 answers

✓ Accepted answer

You need to inser player in the FireClient(), so please replace your script to this:

game.Players.PlayerAdded:Connect(function(player)
    script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
	    game.ReplicatedStorage.ShowCodeGUI:FireClient(player)
        end
    end)
end)

This should work.

1 comment

0

thanks

Like the other comment by Gabe, You have to specify a player. It says "argument one missing" because the argument one should be the player your trying to send an input to!

This doesn't apply to :FireAllClients(), arguments are not necessary since it sends the fire info to each person.

Also, for something to happen when you fire the client, you have to add a .OnClientEvent function (heres an example:)

local remote = game.ReplicatedStorage.ShowCodeGUI
remote.OnClientEvent:Connect(function(arguments from server)
	print('client has been fired!!')
end)

obviously you'd change "arguments from server" and the code inside the function, but you should get the idea.

1 comment

0

Yes, and you can use LocalPlayer for the Client side.

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