Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make an Equip/Unequip system?

Asked by 3 years ago

I just need to know how to make it so when you click a brick if you have enough cash, you get a tool, then you click it again, it removes the tool from your backpack.

Any help is appreciated! thanks!

1 answer

Log in to vote
0
Answered by
sydre 229 Moderation Voter
3 years ago
local brick = workspace.Brick
local cd = Instance.new("ClickDetector")
cd.Parent = brick
local tool = game.ReplicatedStorage.Tool
local cost = 500

cd.MouseClick:Connect(function(plr)
    local plrTool = plr.Backpack:FindFirstChild(tool.Name) or plr.Character:FindFirstChild(tool.Name)
    if plrTool then
        plrTool:Destroy()
    else
        if plr.Money >= cost then
            plr.Money = plr.Money - cost
            plrTool = tool:Clone()
            plrTool.Parent = plr.Backpack
        end
    end
end)

There might be a few typos and you would have to change the variables but this is the general crux of how you would do it.

Ad

Answer this question