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

I'm confused about firing a remote event from a part to a client. Geting Argument 1 missing or nil?

Asked by 5 years ago

So basically I need a script that does stuff with GUI's so I would like it to be in a GUI because when the remote event is fired by a click detector in a part it will do what is said in the GUI script when clicking that part which fires the event. For some reason when I try to fire it from the part it gives the error above in the title. Code below.

The click detector code:

local RepStorage = game:GetService("ReplicatedStorage")
local StartHacking = RepStorage:WaitForChild("StartHacking")

script.Parent.MouseClick:Connect(function()
    StartHacking:FireClient()
end)

The client-side script (In GUI):

local repStorage = game:WaitForChild("ReplicatedStorage")
local StartHacking = repStorage:WaitForChild("StartHacking")


-- When StartHacking is called it dose
StartHacking.OnClientEvent:connect(function()
    script.Parent:Clone().Parent = game.StarterGui
    script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Visible = true
    script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Starting.Text = "Starting..."
    script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Starting.Visible = true
wait(4)
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Starting.Complete.Value = true
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Starting.Text = "Done"
wait(2)
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Starting.Visible = false
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Exploiting.Visible = true
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Exploiting.Text = "Exploiting..."
wait(2)
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Exploiting.Visible = false
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Error.Visible = true
script.Parent.Parent.Parent.StarterGui.LevelOneHacking.Frame.Error.Text = "We got in but the security cameras are still enabled! Press Me to disable them."
end)

1 answer

Log in to vote
1
Answered by
ffejyos 10
5 years ago

To fire the client you must specify the player you wish to fire to. That would be the missing argument.

EX: StartHacking:FireClient(game.Players.appleprogrammer_59)

Inside your function parameters you can put (plr). This will get you the player that touched the part which you can replace appleprogrammer_59 with.

local RepStorage = game:GetService("ReplicatedStorage")
local StartHacking = RepStorage:WaitForChild("StartHacking")

script.Parent.MouseClick:Connect(function(player)
    StartHacking:FireClient(player)
end)

This corrected code will send the event to the client.

Ad

Answer this question