Why isn't this If statement being met?

Hey there,

i’m not sure if im missing something obvious here as i’m fairly new to scripting but i can’t seem to figure this out

Code:

main.Ghosts.MouseButton1Down:Connect(function()
if killeffectghosts and killeffectghosts.Value == false then
status2.Value = “Unequip”
equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
equipbuttonghosts.TextColor3 = Color3.new(0.176471, 0, 0)
equipsound:Play()
ghostsequip()
elseif killeffectghosts and killeffectghosts.Value == true then
status2.Value = “Equip”
equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
equipbuttonghosts.TextColor3 = Color3.new(0, 1, 0)
ghostsequip()
elseif not killeffectghosts and requirement.Value < 50 then errorsound:Play()
print(“Cant Afford”)
elseif not killeffectghosts and requirement.Value >= 50 then ghostsequip()
buysound:Play()
print (“Bought”)
end
end)

When the player buys the effect and clicks it again to Equip it gets stuck in that Elseif statement as if they are buying it over and over and not checking if its True/False as it is intended on the first lines.

Thanks,

*btw it updates as supposed to when the player resets

Maybe set the killeffectghost.Value to false right after the elseif, the script is reading that bool as true cause it hasn’t been deactivated.
Edit: I mean set the bool that says that the product has been bought to false so it doesn’t stay in a bought loop. I’m also reviewing every bit of the code and see if we can organize it.
Edit 2: Bro what are your terms here, what is ‘main’ what is ‘requirement’, are you in a local script or server script? If you can help me by giving the terms meaning like a screenshot of explorer or the locals in the code, I don’t know where we are working at here.

Format code moment

main.Ghosts.MouseButton1Down:Connect(function()
    if killeffectghosts and killeffectghosts.Value == false then
        status2.Value = “Unequip”
        equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
        equipbuttonghosts.TextColor3 = Color3.new(0.176471, 0, 0)
        equipsound:Play()
        ghostsequip()
    elseif killeffectghosts and killeffectghosts.Value == true then
        status2.Value = “Equip”
        equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
        equipbuttonghosts.TextColor3 = Color3.new(0, 1, 0)
        ghostsequip()
    elseif not killeffectghosts and requirement.Value < 50 then errorsound:Play()
        print(“Cant Afford”)
    elseif not killeffectghosts and requirement.Value >= 50 then ghostsequip()
        buysound:Play()
        print (“Bought”)
    end
end)

I don’t think you’re supposed to keep checking for the killeffectghosts (Whether it be checking if it’s valid or not) but instead you can try this?

main.Ghosts.MouseButton1Down:Connect(function()
    if killeffectghosts.Value == false then
        status2.Value = “Unequip”
        equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
        equipbuttonghosts.TextColor3 = Color3.new(0.176471, 0, 0)
        equipsound:Play()
        ghostsequip()
    elseif killeffectghosts.Value == true then
        status2.Value = “Equip”
        equipbuttonghosts.Text = status2.Value print(player.KillEffects.Blocks.Value)
        equipbuttonghosts.TextColor3 = Color3.new(0, 1, 0)
        ghostsequip()
    elseif requirement.Value < 50 then 
        errorsound:Play()
        print(“Cant Afford”)
    elseif requirement.Value >= 50 then 
        ghostsequip()
        buysound:Play()
        print (“Bought”)
    end
end)