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

Why won't the value of this change?

Asked by 10 years ago
pagenum = ""
local pgnum = script.Parent.Parent.PGNUM.Value
if pgnum == "2" then
    function onclicked()
        pagenum = 2-1
        pgnum = 2
        script.Parent.Parent.pg.Text = "Page "..pagenum..""
        script.Parent.Parent.pg1.Visible = true
        script.Parent.Parent.pg2.Visible = false
    end
end

script.Parent.MouseButton1Down:connect(onclicked)

It's supposed to act like a click change page type thing. You click the right arrow, it changes pgnum to 2, then left arrow checks if the value of pgnum is 2. if it is then if you press the left arrow it will go back to page 1

but the value doesn't change, why?

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 years ago
pagenum = 0
local pgnum = script.Parent.Parent.PGNUM --This is setting the actual value of the value as a variable, not the instance itself.
function onclicked()
        if pgnum.Value == "2" then --This should be inside the function.
        pagenum = "" ..2-1.. "" --Should be a string since you will concatenate it.
        pgnum.Value = 1
        script.Parent.Parent.pg.Text = "Page "..pagenum..""
        script.Parent.Parent.pg1.Visible = true
        script.Parent.Parent.pg2.Visible = false
        end
end

script.Parent.MouseButton1Down:connect(onclicked)
Ad

Answer this question