Hey so im still trying to make my inventory system but I came across this error onto which idk how to fix
The error is on line 24, remote script and line 43 on localscript.
I’m not good at explaining but it’s supposed to do something.
When the localscript Invokes the server, the localscript will also give an “items.name” and when the localscript invokes the script but instead it’s for unequipping, it’ll also give an items.name still, but the remotes script will instead invoke the client and transfer that “items.name” argument but it wont work for some reason
Remote Script (Error is here)
local rs = game:GetService("ReplicatedStorage")
local invremo = rs.RemoteEvents.Inventory.Inventory
local itemstorage = rs.Item
local fruits = itemstorage.Fruits
local weapons = itemstorage.Weapons
invremo.OnServerInvoke = function(plr, item, condition, itemtype)
if condition == "Equipped" then
if itemtype == "Weapon" then
local cloneitem = weapons[item]:Clone()
cloneitem.Parent = plr.Backpack
cloneitem["Owner"].Value = plr
cloneitem["Equip"]:Destroy()
print("Equipped " .. item)
return cloneitem
elseif itemtype == "Fruit" then
local cloneitem = fruits.Fruit[item]:Clone()
cloneitem.Parent = plr.Backpack
cloneitem["Owner"].Value = plr
print("Equipped " .. item)
return cloneitem
end
elseif condition == "Unequipped" then
invremo:InvokeClient(item)
--[[for index, equipped in pairs(plr.Backpack:GetChildren()) do
if equipped.Name == item then
local lol = plr.Backpack[item]
lol:Destroy()
end
end
for index, chrlo in pairs(plr.Character:GetChildren()) do
if chrlo:IsA("Tool") and chrlo.Name == item then
chrlo:Destroy()
end
end --]]
end
end
Local Script (InvokeClient)
local rs = game:GetService("ReplicatedStorage")
local invremo = rs.RemoteEvents.Inventory.Inventory
local inventorygui = script.Parent.Parent.Parent.InventoryFrame
local itemdisplayed = script.Parent.ItemDisplayed
local plr = game.Players.LocalPlayer
local cooldown = false
for i, child in pairs(script.Parent:GetChildren()) do
if child:IsA("TextButton") then
child.MouseButton1Click:Connect(function()
if child.Name == "Equip" then
if child.Text == "Equip" then
for i, items in pairs(inventorygui:GetChildren()) do
if items:IsA("ImageButton") and cooldown == false then
if script.Parent.ItemDisplayed.Value == items and items.Equipped.Value == false then
if script.Parent.ItemDisplayed.Type.Value == "Weapon" then
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Click:Play()
items.Equipped.Value = true
items.Tool.Value = invremo:InvokeServer(items.Name, "Equipped", "Weapon")
print("Activated Remote 1")
child.Text = "Unequip"
cooldown = true
wait(0.5)
cooldown = false
elseif script.Parent.ItemDisplayed.Type.Value == "Fruit" then
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Click:Play()
items.Equipped.Value = true
items.Tool.Value = invremo:InvokeServer(items.Name, "Equipped", "Fruit")
print("Activated Remote 1")
child.Text = "Unequip"
cooldown = true
wait(0.5)
cooldown = false
end
end
end
end
elseif child.Text == "Unequip" then
for i, items in pairs(inventorygui:GetChildren()) do
if items:IsA("ImageButton") and cooldown == false then
if script.Parent.ItemDisplayed.Value == items and items.Equipped.Value == true then
invremo:InvokeServer(items.Name, "Unequipped", "Weapon")
end
end
end
end
end
end)
end
end
invremo.OnClientInvoke = function(plr, value)
for i, v in pairs(inventorygui:GetChildren()) do
if v:IsA("ImageButton") and script.Parent.ItemDisplayed.Value == v then
for i, k in pairs(plr.Backpack:GetChildren()) do
if k.Name == value then
if v.Tool.Value == k then
k:Destroy()
v.Tool.Value = nil
end
end
end
end
end
end
--[[ if script.Parent.ItemDisplayed.Type.Value == "Weapon" then
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Click:Play()
items.Equipped.Value = false
print("Activated Remote 2")
child.Text = "Equip"
cooldown = true
wait(0.5)
cooldown = false
elseif script.Parent.ItemDisplayed.Type.Value == "Fruit" then
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Click:Play()
items.Equipped.Value = false
invremo:InvokeServer(items.Name, "Unequipped", "Fruit")
print("Activated Remote 2")
child.Text = "Equip"
cooldown = true
wait(0.5)
cooldown = false
end --]]```