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

Script can't go past line 12?

Asked by
lomo0987 250 Moderation Voter
9 years ago

It stops when it hits... if pos.Value == "0" then on line 12.. I know it's correct but it doesn't go through.. No errors or anything like that.

GUI = script.Parent
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
pos = script.Parent.Pos
debounce = true

function keydown(key)
    print(key)
    key = key:lower()
    print(key)
    if key == "q" then
        if pos.Value == "0" then
            if debounce == true then
                print(debounce)
                debounce = false
                print(debounce)
                GUI:TweenPosition(UDim2.new(1, -100, 1, -100), "Out", "Elastic")
                pos.Value = "1"
            else
                GUI:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Elastic")
                pos.Value = "0"
                print(debounce)
            end
            debounce = true
        end
    end
end

mouse.KeyDown:connect(keydown)

1 answer

Log in to vote
2
Answered by 9 years ago

If pos is an integer value then you don't need to include the quotation marks around the number. pos.Value == "1" is pretty much asking if the value of pos is a string 1 not a number 1. You would use pos.Value == 1 to check to see if it's equal to 1. I have fixed it for you.

GUI = script.Parent
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
pos = script.Parent.Pos
debounce = true

function keydown(key)
    print(key)
    key = key:lower()
    print(key)
    if key == "q" then
        if pos.Value == 0 then
            if debounce == true then
                print(debounce)
                debounce = false
                print(debounce)
                GUI:TweenPosition(UDim2.new(1, -100, 1, -100), "Out", "Elastic")
                pos.Value = 1
            else
                GUI:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Elastic")
                pos.Value = 0
                print(debounce)
            end
            debounce = true
        end
    end
end

mouse.KeyDown:connect(keydown)

0
LOL, opps. I was quite tired when I was coding this... I didn't realize that I did that. lomo0987 250 — 9y
Ad

Answer this question