help with check if there is a weapon in slot 6?

what would you do if you wanted to check if there is a weapon or any item in the players slot 6

in sandbox slot 6 would have the tool gun and camera

or in ttt would be were the T bought items would go

i would like this because i would like to make a if statement that is if there is a weapon in slot 6 do not do this

thank you for reading i hope i can get some help

You could try looping through the player’s weapons and doing Weapon:GetSlot to check if the slot is empty-i’ll post an example soon

thanks for the quick reply man :smiley:

Try this:

local function SlotFull( ply, slot ) -- a handy little function to use

	slot = slot - 1 -- take away 1 from the slot number you want since I think it starts from 0 (the crowbar is apparently in slot 0 rather than slot 1)

	local weptbl = ply:GetWeapons() -- get all the weapons the player has
	for k,v in pairs( weptbl ) do -- loop through them

		if v:GetSlot() == slot then return true end -- check if the slot is the slot you wanted to check, if it is, return true

	return false -- otherwise return false


I didn’t test it, but you can :stuck_out_tongue:

EDIT: Just tested it, and I think you need to take away 1 from the slot number for it to work. I updated my example.

Anyway, if you wanted that function to do what you said in the first post, all you need to do is something like this:

if SlotFull( LocalPlayer(), 6 ) then

	-- Do stuff


i believe i got what i needed from that thank you man you are amazing