String Expected Got nil

:information_source: I’m making a skill points shop GUI (You can essentially buy skills using skill points earned by levelling up, which can then be used to upgrade stats like general damage, speed, etc. etc.), which displays the amount of skill points the player has already put into the specific skill they have selected.

:question: Where the script buggers up, is when the amount of skill points gets returned to the local script, where it prints (as an error) into the output:

ServerScriptService.Skills.Skills:12: invalid argument #2 (string expected, got nil)

:scroll: Here’s the scripts:

local script
local RS = game:GetService("ReplicatedStorage")

local Info = script.Parent.Parent.Parent.Parent:WaitForChild("Info")

local SelectedItem = script.Parent.Parent.Parent.Parent:WaitForChild("SelectedItem")

local ItemImage = Info.ItemImage
local ItemCount = Info.SkillPoints
local ItemName = Info.ItemName
local ItemOwned = Info.Owned
local ItemEquipped = Info.Equipped
local BuyButton = Info.Buy

script.Parent.MouseButton1Click:Connect(function(player, Name)
	SelectedItem.Value = script.Parent.Name
	local Count = RS.Skills.GetCount:InvokeServer(player, script.Parent.Name) -- ServerScriptService.Skills.Skills:12: invalid argument #2 (string expected, got nil)
	ItemCount.Text = Count
	ItemOwned.Value = Count
and the server script

local replicatedStorage = game:GetService("ReplicatedStorage")

local Name = script.Name

local RSbin = replicatedStorage:WaitForChild(Name)


RSbin.GetCount.OnServerInvoke = function(player,skill)

return player.Skills[skill].Value -- Relays back


:question: What I would like to know is how I could fix the script so that the number gets logged.

You don’t have to send player. Just send the string you want to invoke from client.

1 Like

Sorry last post didn’t highlight what I was referring to. Just remove player from the arguments. Roblox handles sending player to the RemoteFunction so you just have to send arguments after player.

1 Like

The player argument is automatically sent, just send one argument instead as previously mentioned.
local Count = RS.Skills.GetCount:InvokeServer(script.Parent.Name)

1 Like

Hey it works, thanks! :smiley: :smiley: :smiley: