Check if player has accessory - SHOP

So im scripting a tools shop and one item in my shop stands out. It is night vision, when the player buys it and equips it the tool will destroy. but that means the player can buy the same tool and do it again heres a clip

local Event = game.ReplicatedStorage.OtherRemotes.Buy
local Allowed = false

local Accessorys = {
	"NightVisionAcc"
	
}

Event.OnServerEvent:Connect(function(Player, Selection, Price, Name)	
	print("Event fired")
	local Gui = Player.PlayerGui:WaitForChild("MainGui")
	if Selection == Name or Accessorys then
		if Player.Character:FindFirstChild(Name) or Player.Backpack:FindFirstChild(Name) then
			
			print("You have this tool already")
		else
			local Tool = game.ServerStorage:FindFirstChild(Name):Clone()
			Tool.Parent = Player.Backpack
		end
	end
end)

``` shop code
1 Like

You could have a folder within the player’s character or backpack which has boolvals named after the tools you want to equip. If the player has it equipped the equivalent boolval could be true else it would be false. That way you could do a simple:

if Player.Character:FindFirstChild(Name) or Player.Backpack:FindFirstChild(Name) or Player.Character.AccessoryFolder:FindFirstChild(Name) == true then
1 Like