Hello! I have this error in my game: “Argument 1 missing or nil”. It has never appeared before, it only started yesterday. I’ve tried everything on the DevForum and everything I’ve looked at so far hasn’t applied to me. If someone could shed some light on what’s going on, I’d be very appreciative!
Here’s the server code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local events = ReplicatedStorage:WaitForChild("Events")
local abilities = ReplicatedStorage:WaitForChild("Abilities")
events.ShopEvent.OnServerInvoke = function(player, perk, price)
if player then
if player:FindFirstChild("Tokens") and player.Tokens.Value >= price then
player.Tokens.Value -= price
if abilities:FindFirstChild(perk) and not player.abilities:FindFirstChild(perk.Name) then
local newAbility = abilities[perk]:Clone()
newAbility.Parent = player.abilities
return true
else
return false
end
else
return false
end
else
return false
end
end
The error seems to occur on line 12 which is this:
if abilities:FindFirstChild(perk) and not player.abilities:FindFirstChild(perk.Name) then
Here is the client code:
local purchaseSuccess = events.ShopEvent:InvokeServer(ability.Name, ability.Price.Value)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local events = ReplicatedStorage:WaitForChild("Events")
local abilities = ReplicatedStorage:WaitForChild("Abilities")
On the client, the “perk” variable is sent as a string. On the first comparation it was comparing a string, but for some reason this one is comparing as an Instance. Remove “.Name” from it and it should work fine (I think)
I tried it and it didn’t work, but it didn’t give me an error either which probably means that it returned false. Maybe because FindFirstChild only works with strings.