Hello, i’m just trying to wonder how can i destroy a certain quantity of tools, like, i’m making a upgrade machine but i just don’t know how to destroy the tools quantity.
Below is a screenshot what i want to do.
Hello, i’m just trying to wonder how can i destroy a certain quantity of tools, like, i’m making a upgrade machine but i just don’t know how to destroy the tools quantity.
Below is a screenshot what i want to do.
well, without any sort of visuals telling me where everything is, and what scripts you have, I can’t really help you too well.
I suggest using a for i, v
loop inside of the convert button’s click function where v
will check if it’s a key and i
will increase by 1 for every key that is found in whatever folder/model place you are storing them.
check if i >= 10
and if it is, you can destroy the keys by saying v:Destroy()
since you’ve already referenced that “v” is a key that is needed to help convert into the other key.
Hope this helps.
I made a script, but it doesn’t destroy all the keys
Below, the script.
local ConvertFrame = script.Parent
local KeySelectFrame = ConvertFrame.KeySelectFrame
local ConvertButton = ConvertFrame.ConvertButton
local FirstKeyImage = ConvertFrame.FirstKeyImage
local SecondKeyImage = ConvertFrame.SecondKeyImage
local EqualToLabel = ConvertFrame.EqualToLabel
local ButtonTable = {
NormalKeyButton = KeySelectFrame.NormalButton;
GoldenKeyButton = KeySelectFrame.GoldenButton;
DiamondKeyButton = KeySelectFrame.DiamondButton;
AmethystKeyButton = KeySelectFrame.AmethystButton
}
local PlayerService = game:GetService("Players")
local LocalPlayer = PlayerService.LocalPlayer
local PlayerBackpack = LocalPlayer.Backpack
ButtonTable.NormalKeyButton.MouseButton1Click:Connect(function()
FirstKeyImage.Visible = true
SecondKeyImage.Visible = true
EqualToLabel.Visible = true
FirstKeyImage.Image = ButtonTable.NormalKeyButton.Image
SecondKeyImage.Image = ButtonTable.GoldenKeyButton.Image
ConvertButton.MouseButton1Click:Connect(function()
for Index, Value in pairs(PlayerBackpack:GetChildren()) do
if Index >= 10 and Value.Name == "NormalKey" then
Value:Destroy()
end
end
end)
end)
ButtonTable.GoldenKeyButton.MouseButton1Click:Connect(function()
FirstKeyImage.Visible = true
SecondKeyImage.Visible = true
EqualToLabel.Visible = true
FirstKeyImage.Image = ButtonTable.GoldenKeyButton.Image
SecondKeyImage.Image = ButtonTable.DiamondKeyButton.Image
ConvertButton.MouseButton1Click:Connect(function()
for Index, Value in pairs(PlayerBackpack:GetChildren()) do
if Index >= 10 and Value.Name == "GoldenKey" then
Value:Destroy()
end
end
end)
end)
ButtonTable.DiamondKeyButton.MouseButton1Click:Connect(function()
FirstKeyImage.Visible = true
SecondKeyImage.Visible = true
EqualToLabel.Visible = true
FirstKeyImage.Image = ButtonTable.DiamondKeyButton.Image
SecondKeyImage.Image = ButtonTable.AmethystKeyButton.Image
ConvertButton.MouseButton1Click:Connect(function()
for Index, Value in pairs(PlayerBackpack:GetChildren()) do
if Index >= 10 and Value.Name == "DiamondKey" then
Value:Destroy()
end
end
end)
end)
ButtonTable.GoldenKeyButton.MouseButton1Click:Connect(function()
FirstKeyImage.Visible = true
SecondKeyImage.Visible = true
EqualToLabel.Visible = true
FirstKeyImage.Image = ButtonTable.GoldenKeyButton.Image
SecondKeyImage.Image = ButtonTable.DiamondKeyButton.Image
ConvertButton.MouseButton1Click:Connect(function()
for Index, Value in pairs(PlayerBackpack:GetChildren()) do
if Index >= 10 and Value.Name == "AmethystKey" then
Value:Destroy()
end
end
end)
end)
you’re not increasing index by anything, it’s just checking if i >= 10
, but because it remains at 0, it doesn’t do anything
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.