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

Why won't this work?

Asked by
k1nq 30
7 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
function onClicked(player)
    local item = game.ServerStorage.Items.Logs:Clone()
    local gui = player.PlayerGui.ScreenGui.MainGui.Guis.Backpack
    if gui.B1.Used.Value == nil then
        item.Parent = gui.B1
        item.Parent.Image = game.ServerStorage.Items.Logs.ItemPic.Value
        item.Parent.Used.Value = "Logs"
    end
    if gui.B1.Used.Value ~= nil and gui.B2.Used.Value == nil then
        item.Parent = gui.B2
        item.Parent.Image = game.ServerStorage.Items.Logs.ItemPic.Value
        item.Parent.Used.Value = "Logs"
    end
    if gui.B1.Used.Value ~= nil and gui.B2.Used.Value ~= nil then
    end
    print("Nil")
end

script.Parent.Model.Root.ClickDetector.MouseClick:connect(onClicked)

So, basically the used value is nil and it's still just going all the way through and printing "nil" anyway to make this work?

0
It's printing Nil because the print function is outside of all the if statements. Might I also suggest using elseif rather than creating a new if then statement each time? M39a9am3R 3210 — 7y
0
Not to ask for too much of you, but mind writing it out? I've tried elseif statements also but they wouldn't work. k1nq 30 — 7y
0
Just instead of the end and if on lines 8 and 9, put elseif on line 9 and delete the end. Same for lines 13 and 14. GoldenPhysics 474 — 7y

Answer this question