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

Why isn't this size improver script not working when the value is over 20?

Asked by 8 years ago

When size is more then 20 its supposed to print("Over 20") why isn't it working? When it is over 20 it doesnt do anything instead the value of size keeps going.Test it and you will see

player = script.Parent.Parent
char = player.Character
mouse = player:GetMouse()
hold = false
function keydown(key)
    key = key:lower()
    if key == "z" then
        hold = true
        bricksize()
    end
end


function bricksize()
    size = 0
    if size > 20 then
        hold = false
        print("OVer 20")
    end
    while hold == true do
    wait()
    size = size+1
    print(size)
    end
end


function keyup(key)
    key = key:lower()
    if key == "z" then
        hold = false
    end
end


if hold == false then
    size = 0
end
mouse.KeyDown:connect(keydown)
mouse.KeyUp:connect(keyup)

1 answer

Log in to vote
0
Answered by 8 years ago

I changed a bit around the bricksize function, here you go, this should work.

player = script.Parent.Parent
char = player.Character
mouse = player:GetMouse()
hold = false
function keydown(key)
    key = key:lower()
    if key == "z" then
        hold = true
        bricksize()
    end
end


function bricksize()
    size = 0
    while hold == true do
    wait()
        if size > 20 then
            hold = false
            print("OVer 20")
        else
            size = size+1
            print(size)
        end
    end
end

function keyup(key)
    key = key:lower()
    if key == "z" then
        hold = false
    end
end


if hold == false then
    size = 0
end
mouse.KeyDown:connect(keydown)
mouse.KeyUp:connect(keyup)
0
Nothing changed coolg5555 70 — 8y
0
Weird, when I tested it reached 21 then said"OVer 20" and did not continued. Did you have it in StarterGui? aaron8888 3 — 8y
Ad

Answer this question