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

What is wrong with my Reload Script?

Asked by 10 years ago

So it all works, changes the Gui etc, but it doesn't do it smoothly. It just skips straight to 12, rather than waiting and changing it by 1 every 0.1 of a second. What is wrong with my code?

        mouse.KeyDown:connect(function(key)
            local key = string.lower(key)
            if key == "r" then
                if ammo < 12 then
                    repeat
                        ammo = ammo + 1
                        clone.Ammo.Text = ammo.."/12"
                        wait(0.1)
                    until
                        ammo == 12
                end --end if ammo < 12
            end --end if key == "r"
        end) --end keydown function

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

I can't think of why it might be skipping the rest, but try this code:

mouse.KeyDown:connect(function(key)
    local key = string.lower(key)
    if key == "r" then
        while ammo < 12 then
            ammo = ammo + 1
            clone.Ammo.Text = ammo .. "/12"
            wait(0.1) -- One tenth of a second is a *very* short time.
        end
    end
end)

Maybe your problem is just that it reloads so fast, you simply can't see 1 through 11?

Ad

Answer this question