Conditions being met, nothing happening

Well Im not using actual objects everything is in scripts using tables

Then perhaps you’d have to use some sort of listener to fire to your script once the player gets an item. I was going to say use an infinite loop, but I’d discourage against using those, as it’s inneficient and in most cases there’s a better way to go about things.

Could you provide more info about what you’re doing? Like, when does this script activate - when something happens, or what?

this is literally the whole script

remote.OnServerEvent:Connect(function(plr,info)
	local Inventory = _G.PlayerData[plr.UserId]["Inventory"]
	info[3]:Destroy()
	if info[2] > 3 or info[2] < 1 then
		plr:Kick("Imagine trying to change an item's val . . . ")
	end
	local function UpdateUI()
		local InventoryUI = plr.PlayerGui:WaitForChild("Inventory")
		local Template = InventoryUI.InventoryTemplates.ImageButton:Clone()
		local InventoryFrame = InventoryUI.main.InventoryFrame
		Template.Visible = true
		Template.Parent = InventoryFrame
	end
	UpdateUI()
end)

When does the RemoteEvent fire to the server?

the itemname,iteminstance and the value

Oh sorry, I meant when, not what

Its when i pick up something

local debounce = false
uis.InputBegan:Connect(function(i,t)
	if t then return end
	if i.KeyCode == Enum.KeyCode.F and not debounce then
		debounce = true
		local function Pickup()
			for i,v in pairs(game.Workspace.Items:GetChildren()) do
				for index,tabl in pairs(ItemStorage.Items) do
					if v:IsA("Part") and v.Name == ItemStorage.Items[index][1] and (humrp.Position - v.Position).Magnitude < 5 then
						remote:FireServer(v.Name,math.random(1,3),v)
					end
				end
			end
		end
		Pickup()
		wait(.35)
		debounce = false
	end
end)

I advise adding a print statement above the condition to print the same thing (Inventory[idx][1] or simply tabl[1] as it’s the same thing) to check what the value actually is and know for certain the condition truly is met.

Yeah I tried something of that nature and its still not working or printing out anything

Try doing some debugging using print().

EDIT: Whoops, didn’t see @BanTech 's reply yet

Ive tried debugging and tried printing out Inventory[idx][1] before the if statement and it works

What did it print in this statement? false? nil?

Try printing inside of the if statement. That’ll tell you for sure if the conditions are being met.

@BanTech
@MJTFreeTime
I decided to get rid of the table and just use single arguments and when I dont insert it into the table it prints nothing at all in the console

remote.OnServerEvent:Connect(function(plr,itemname,value,iteminstance)
	local Inventory = _G.PlayerData[plr.UserId]["Inventory"]
	iteminstance:Destroy()
	if value > 3 or value < 1 then
		plr:Kick("Imagine trying to change an item's val . . . ")
	end
	for idx,tbl in ipairs(Inventory) do
		print(Inventory[idx][1])
	end
	local function UpdateUI()
		local InventoryUI = plr.PlayerGui:WaitForChild("Inventory")
		local Template = InventoryUI.InventoryTemplates.ImageButton:Clone()
		local InventoryFrame = InventoryUI.main.InventoryFrame
		Template.Visible = true
		Template.Parent = InventoryFrame
	end
	UpdateUI()
end)

What I pass onto the server

There’s one problem that could happen. You’re passing “math.random(1,3)”, which I believe picks 1 or 3, and any number in between. Then in your script you say:

if value > 3 or value < 1 then
		plr:Kick("Imagine trying to change an item's val . . . ")
	end

You’ll probably want to make it this:

if value >= 3 or value <= 1 then
		plr:Kick("Imagine trying to change an item's val . . . ")
	end

EDIT: The thing is, it could land on 1 or 3. Then, the way you have it now, it wouldn’t meet the conditions, as you’re only checking between 1 and 3.

It’s probably not the main problem, but something on the side to check.

changing it wouldnt really help… im checking to see if the number that the server receives is between 1 and 3, not any lower than 1 and not any higher than 3 if I tried your method if the player got 3 it would kick them and if they got 1 it would kick them

Ah okay.

So, when you put a print() inside of the if satement does it print anything? Try to pinpoint what in your system isn’t working exactly.

welp i fixed it i just defined pre values in the inventory table and check if they are 0 or not and its working great

Using global variables is considered bad practice and won’t deliver information too accurately. I too did this and learned my lesson. Here’s more information about it and the thread.

Using ModuleScripts is recommended and perhaps it might solve your problem.

EDIT: I see that the problem has already been fixed, but I would still steer away from global variables and not rely on them too much.

I only rely on them to use userdata thats literally all I use them for