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

FireClients (need explanation please!) [?]

Asked by 3 years ago

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.

0
I have answered, you may look below at the answers. Gabe_elvin1226aclan 323 — 3y

2 answers

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

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.

0
thanks rayhansatria 142 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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.

0
Yes, and you can use LocalPlayer for the Client side. Gabe_elvin1226aclan 323 — 3y

Answer this question