How to only equip one item on simulator shop

Hello,

I am sure many of you have seen the shops on some simulators when they use camera manipulation
and all that other stuff.
so the only problem I had with this is I can’t figure out how to eqiup only one weapon at a time.

this is my buy script.

game.ReplicatedStorage.ShopBuy.OnServerEvent:Connect(function(player,page)
local tool = game.ReplicatedStorage:WaitForChild(“Tools”)
local shop = game.Workspace.Shop
local clone = tool:FindFirstChild(shop:FindFirstChild(“Part”…page).ItemName.Value):Clone()
local clone2 = tool:FindFirstChild(shop:FindFirstChild(“Part”…page).ItemName.Value):Clone()
clone.Parent = player.Backpack
clone2.Parent = player.StarterGear – So that the player wont lose item when they die
end)

And this is when a player taps on the buy circle

game.ReplicatedStorage.TriggerCam.OnClientEvent:Connect(function()
	local player = game.Players.LocalPlayer
	local shop = player.PlayerGui.Shop
	local camera = workspace.CurrentCamera
	local mainshop = workspace.Shop
	local item = shop.Item
	local buy = shop.Frame.Buy
	local shadow = buy.Shadow

if shop.Closed.Value == false then
		if shop.Open.Value == false then
			shop.Open.Value = true
			shop.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Quint",1,true)
			shop.Item.Value = 1
			camera.CameraType = Enum.CameraType.Scriptable
			camera.CameraSubject = mainshop.Cam1
			camera.CFrame = mainshop.Cam1.CFrame
			shop.Frame.TextLabel.Text = mainshop:FindFirstChild("Part"..shop.Item.Value).ItemName.Value
			shop.Frame.Buy.Text = mainshop:FindFirstChild("Part"..shop.Item.Value).ItemPrice.Value
			game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
			if player.Backpack:FindFirstChild(workspace.Shop:FindFirstChild("Part"..item.Value).ItemName.Value) ~= nil then
				buy.Text = "Bought"
				buy.BackgroundColor3 = Color3.new(0.7,0.7,0.7)
				shadow.BackgroundColor3 = Color3.new(0.5,0.5,0.5)
			else
				buy.Text = workspace.Shop:FindFirstChild("Part"..item.Value).ItemPrice.Value
				buy.BackgroundColor3 = Color3.fromRGB(85,255,127)
				buy.BackgroundColor3 = Color3.fromRGB(70, 212, 104)
			end
		end
	end
end)

so it is equiping more than 1 item.
help would be heavily appreciated.

Thank you for reading.

7 Likes

If there is nothing else in the Players Backpack, you can just use :ClearAllChildren() on the Backpack and StarterGear. If there is something else in the Players Backpack, then you can give it a BoolValue named Base or something, then loop through the Backpack/StarterGear like this

local Backpack = Player.Backpack:GetChildren()
for i=1, #Backpack do
  if not Backpack[i]:FindFirstChild("Base") then
    Backpack[i]:Destroy()
  end
end

This will then destroy all tools in the players Backpack which do not have the BoolValue named Base in them.

1 Like

There is a Tutorial make by AlvinBlox how to make mining shop simulator

Link : https://m.youtube.com/watch?v=7Bn1KfDDQu0

3 Likes

It doesn’t let me equip any items.
Sorry.

Before you add new items into the player’s backpack, clear all the children of the backpack by using backack:ClearAllChildren() and then add in the new item.
Hope it helps! :grinning:

1 Like