So I'm currently trying to send the Value of an ObjectValue using a RemoteFunction.
In a LocalScript:
local store_item = game.ReplicatedStorage:WaitForChild("Store_Item") local selected_item = script.Parent.Edit:WaitForChild("Selected_Item") script.Parent.Edit.Inventory.MouseButton1Click:connect(function() store_item:InvokeServer(selected_item.Value) edit.Visible = false end)
In a Script:
local store_item = game.ReplicatedStorage:WaitForChild("Store_Item") function store_item.OnServerInvoke(player, selected_Item) local id = selected_Item:WaitForChild("Item_ID").Value local name = selected_Item:WaitForChild("Item_Name").Value wait(0.5) selected_Item:Destroy() player.PlayerGui.ScreenGui.AddSlot:Invoke(id, name) end
When I test in Play Solo, it work's fine. However in a Local Server it gives me the following error.
attempt to index local 'selected_item' (a nil value)
I'm not sure of the issue... any help is appreciated.
I believe the reason why it can't index selected_item is because when the server start it hasn't properly loaded. You can fix this by setting a variable for selected_Item the same way you did for store_item.
local store_item = game.ReplicatedStorage:WaitForChild("Store_Item") local selected_item = (game.ReplicatedStorage:WaitForChild("Selected Item")