I made a script that when the user presses a GUI button a image and a value are created, the first part works fine along with the part that hides the image again, but the value does not get destroyed.
local buttonID = ("A1")
local pressedBefore = false
script.Parent.MouseButton1Click:connect(function()
local int = Instance.new("StringValue",game.Workspace.intHolder)
int.Name = buttonID
int.Value = buttonID
if pressedBefore == false then
print("building")
script.Parent.ImageLabel.Visible = true
pressedBefore = true
elseif pressedBefore == true then
print("removing")
script.Parent.ImageLabel.Visible = false
game.Workspace.intHolder[buttonID]:Destroy() --destroy value "A1" from intHolder (model)
pressedBefore = false
end
end)

4 comments
Does this script make any output? Can you put prints to track the variables and determine which if branches actually end up happening?
everything is working, but the destroy, I tried 'int:Destroy()' and it does not work
On line 15, add print(int) to see if it's nil.
It says "A1"