Inventory system save slots

I am still getting issues. I am using one RemoteFunction.
“OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available - Server - Script:9” I dont know what you mean with this.

this is what I am doing in Local script:

equip.MouseButton1Click:Connect(function()

	IntValue.Value = IntValue.Value + 1
	local FiredEvent = RemoteFunction:InvokeServer(IntValue)
	
	if FiredEvent == false then
		print("a")

	elseif FiredEvent == true then
		print("b")
	end
end)

and this is what I am doing in ServerScriptService:

local MaxLimit = 3
RandomToolIMadeUp = game.ReplicatedStorage.Tools.ClassicSword

local RemoteFunction = game:GetService("ReplicatedStorage"):WaitForChild("InvLimit") 

RemoteFunction.OnServerInvoke:Connect(function(Player, IntValue)

	if IntValue >= MaxLimit then

		return false

	elseif IntValue < MaxLimit then

		RandomToolIMadeUp:Clone().Parent = Player.Backpack
		return true
	end
end)

I’m very sorry for messing up a ton with this. I’m more of a RemoteEvent user myself, so if you want, you could make the server handle everything with that one specific IntValue using your RemoteEvent that you had before. I don’t think this does require returning but I figured it would be best to use some form of returning.

To that error in specific, I’m pretty sure it’s erroring because people usually wrote something like this

local function onInvoke(Player, IntValue)

      if IntValue >= MaxLimit then
        return false
    elseif InventorySpaceUsed < MaxLimit then
        RandomToolIMadeUp:Clone().Parent = Player.Backpack

        return true
    end

end

-- completely forgot it's a callback, so you gotta assign the function like so
RemoteFunction.OnServerInvoke = onInvoke

“ServerScriptService.Script:9: attempt to compare number <= Instance”

image

Btw I used IntValue.Value bc if I use IntValue(alr with Value) will not work

IntValue is an instance. I was afraid you were going to have that issue with it not adding.

I recommend making 2 separate variables. One for adding the math* onto the IntValue and another for just the IntValue itself.

Something like:

local IntValueForMath = script:WaitForChild("NameOfIntValue")
local IntValueForFiringServer = script:WaitForChild("NameOfIntValue").Value

Just make sure you plug IntValueForFiringServer into the :InvokeServer() parameters.

I think I not need to make one system so hard for see if the player backpack got +3 tools you can just do
"if #player.Backpack:GetChildren() < limit then" for get all tools inside the backpack.

The problem is going back.

1 Like

I was only recommending IntValues because I I assume when you round up the number, it’s not exactly a variable right? So it’s more difficult to check to see if the player has a full inventory or not because no number is saved.

If you have a solution in mind for this, then please do that instead. I wasn’t using studio, but if I were I would be able to demonstrate this a lot better. Apologies.

but yes you can just add the IntValue ons script and make his value = 3 and use it. without making limit = 3 you can do limit = script:WaitForChild(“IntValue”) and use his value.

1 Like

I recommend always saving some-what decent code before making full changes such as these. I shouldn’t be reliable for that, it’s proper code ettiquette.

That could work too. I wish you luck on figuring this out then. I’m not the person to be helping you unfortunately because I can’t use Studio at this very moment for an issue such as this. Not to mention I need to sleep now.

I’m sorry for causing a bit of a headache.

I can try to replicate your system later and see if I can post a solution.

1 Like

Its ok :slight_smile: Thank you for helping too.

1 Like