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!
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!
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.