I'm trying to transfer some information from a server script into a client script using remote events. And i'm transfering some table information from the server script into the client so hackers wouln't be able to access the code.
I can't seem to get it to work it just prints out an error in the outpot.
Here's my server script code:
local inv = {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
local nextSlot = 1
local currentSlot = 1
function ToolHotbar(slot, empty, item)
RemoteEvents.ToolHotbar:FireClient(slot, empty, item, inv[slot])
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
addItem(nil, "Dirt")
Client script:
local rep = game.ReplicatedStorage
local items = rep.items
local Events = rep.Events;
local RemoteEvents = Events.RemoteEvents;
local gui = script.Parent:WaitForChild("ScreenGui")
local Toolbar = gui.Toolbar
local nextSlot = 1
local currentSlot = 1
RemoteEvents.ToolHotbar.OnClientEvent:connect(function(slot, empty, item, inv)
if (type(inv) ~= "table") then
inv = {inv}
end
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)
Error output:
20:49:29.370 - Unable to cast value to Object
20:49:29.371 - Stack Begin
20:49:29.371 - Script 'ServerScriptService.MainScript', Line 15 - global ToolHotbar
20:49:29.371 - Script 'ServerScriptService.MainScript', Line 35 - upvalue checkIfEmpty
20:49:29.372 - Script 'ServerScriptService.MainScript', Line 40 - global addItem
20:49:29.372 - Script 'ServerScriptService.MainScript', Line 43
20:49:29.373 - Stack End

1 comment
The error output refers to lines a script (or lines in your script) that you haven't posted