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

Argument 1 missing or nil on firing client?

Asked by 3 years ago

So the thing is that when the player touched the object, it fires the remote event for the client and once fired, a gui will show, Any help?

-- Main Script coded in a Script

local function acti()
    _G.Wall1.Disabled = false
    _G.Wall2.Disabled = false

    game.ReplicatedStorage.RemoteEvent:FireClient()
end


script.Parent.Touched:Connect(acti)

-- Receiver coded in a Local Script:

local function activateSpook()
    script.Parent.Enabled = true
end

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(activateSpook)
0
Which line gives that error? GeldiBaskan 13 — 3y
0
Line 5 In main script XxKlydecabuenosxX 25 — 3y

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

You need to fire a player instance when firing to a specific client. Since Touched event returns hit parameter, and you can use hit.Parent for the character. By using :GetPlayerFromCharacter it returns a player instance for the following character. Replace the line 5 as:

game.ReplicatedStorage.RemoteEvent:FireClient(game:GetService("Players"):GetPlayerFromCharacter(hit.Parent))

Hover over the Lua block and press "Open Source" to view the full lua block! (Since it's too long)

Ad
Log in to vote
0
Answered by
niroqeo 123
3 years ago

When using

:FireClient()

you have to add a player in the brackets so the computer knows who to fire the event to. Like so:

:FireClient(player)

Answer this question