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

Error: invalid argument #3 (string expected, got nil)?

Asked by 3 years ago
Edited 3 years ago

I get this error: invalid argument #3 (string expected, got nil). These are the scripts:

Server script:

local rigs = game.Workspace.Rigs:GetChildren()
local event = game.ReplicatedStorage.RigTouched

for _, rig in pairs(rigs) do
    rig.OpenGuiPart.ClickDetector.MouseClick:Connect(function(player)
        local rigID = rig.ClothingID.Value
        event:FireClient(player, rigID)
    end)
end

Local script:

local event = game.ReplicatedStorage.RigTouched
local CurrentClothingID = script.Parent.ShopBackround.CurrentClothing

event.OnClientEvent:Connect(function(player, rigId)
    script.Parent.ShopBackround.Visible = true
    CurrentClothingID.Value = rigId
    print(rigId)
end)

I have read the code several times but still do not understand what is the problem. The error is on line 6 of the local script.

0
Try removing the "player" inside the parameters (Script) because when your firing those event roblox already knows the player so you dont need to put it acediamondn123 147 — 3y
0
To the person above me, this is incorrect. OnClientEvent has no player argument. Only OnServerEvent has this. deeskaalstickman649 475 — 3y

1 answer

Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago
Edited 3 years ago

I see the mistake. You see, only OnServerEvent needs the player argument. OnClientEvent doesn't. So on the local script, do this instead:

local event = game.ReplicatedStorage.RigTouched
local CurrentClothingID = script.Parent.ShopBackround.CurrentClothing

event.OnClientEvent:Connect(function(rigID)
    script.Parent.ShopBackround.Visible = true
    CurrentClothingID.Value = rigId
    print(""..rigID)
end)
0
also, in the server script, you gave the parameter rigID, so on the local script you have to do rigID too instead of rigId NGC4637 602 — 3y
Ad

Answer this question