I'm making this inventory toolbar and it works fine on the clients side but when it comes to making it work on the server side i have a bit of a problem getting the server sided code work with the clients code.
So i'm trying to use the _G function to transfer the clients code to the server but i'm not the best at it so i don't even know if that is possible to transfer the code to make it work with the FE.
I basically want some of the code to be on the client side cause it has to and some of the code to be on the server side just so it works with FE.
Client Script:
local gui = script.Parent:WaitForChild("ScreenGui")
local Toolbar = gui.Toolbar
_G.inv = {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
local nextSlot = 1
local currentSlot = 1
function ToolHotbar(slot, empty, item)
if empty then
local imageID = items[item]:FindFirstChild("imageID").Value
Toolbar["Slot"..nextSlot].itemImage.Image = "rbxassetid://"..imageID
Toolbar["Slot"..nextSlot].itemImage.Visible = true
inv[nextSlot] = item
end
end
local function checkIfEmpty(empty, item)
if inv[nextSlot] ~= nil then
nextSlot = nextSlot + 1
currentSlot = currentSlot + 1
if inv[nextSlot] ~= nil then
nextSlot = nextSlot + 1
end
empty = true
if nextSlot <= 10 then
ToolHotbar(nextSlot, empty, item)
else
print("Your inventory is full please empty it.")
end
else
print("Slot"..nextSlot.. " Is empty, Adding item...")
empty = true
ToolHotbar(nextSlot, empty, item)
end
end
function addItem(empty, item)
checkIfEmpty(empty, item)
end
Server Script:
_G.inv{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
print(_G.inv)
Errors:
19:14:53.072 - ServerScriptService.ServerPlacement:6: attempt to call field 'inv' (a nil value)
19:14:53.072 - Stack Begin
19:14:53.073 - Script 'ServerScriptService.ServerPlacement', Line 6
19:14:53.073 - Stack End

3 comments
https://scriptinghelpers.org/questions/51397/are-global-functions-used-anymore#51082
You're going to want to use RemoteFunctions or RemoteEvents (mattering on how you want the communication to work). More information is available here: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions&redirect=no
Oh, thank you guys for the response.