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

Trouble with destroying a string value?

Asked by 9 years ago

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)
0
Does this script make any output? Can you put prints to track the variables and determine which if branches actually end up happening? BlueTaslem 18071 — 9y
0
everything is working, but the destroy, I tried 'int:Destroy()' and it does not work CaptainRuno 40 — 9y
0
On line 15, add print(int) to see if it's nil. Merely 2122 — 9y
0
It says "A1" CaptainRuno 40 — 9y

Answer this question