Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

2 comments

0

Nothing changed

0

Weird, when I tested it reached 21 then said"OVer 20" and did not continued. Did you have it in StarterGui?

This discussion is preserved as it was. New answers, comments, and votes are closed.