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

How to make this script more efficient?

Asked by
lomo0987 250 Moderation Voter
10 years ago
repeat wait() until game.Players.LocalPlayer
GUI = script.Parent.Parent
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
inuse = script.Parent
debounce = true

function keydown(key)
    key = key:lower()
    if key == "q" and debounce == true then
        debounce = false
            if inuse.Value == "No" then
                debounce = false
                GUI:TweenPosition(UDim2.new(0.5, -350, 0.5, -150), "Out", "Elastic")
                inuse.Value = "Yes"
            elseif inuse.Value == "Yes" then
                GUI:TweenPosition(UDim2.new(0, -1500, 0, 0), "Out", "Elastic")
                inuse.Value = "No"
            end
            debounce = true
    end
end

mouse.KeyDown:connect(keydown)

this is my current script.. Everything works.. Just need it to be a bit more.. efficient? Any way I can do this?

1 answer

Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
10 years ago

I don't see much of anything that you could change that would make it more efficient, I will make one change though.

repeat wait() until game.Players.LocalPlayer
GUI = script.Parent.Parent
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
inuse = script.Parent
debounce = true

mouse.KeyDown:connect(function(key) -- Made connection line and function one line
    key = key:lower()
    if key == "q" and debounce == true then
        debounce = false
            if inuse.Value == "No" then
                debounce = false
                GUI:TweenPosition(UDim2.new(0.5, -350, 0.5, -150), "Out", "Elastic")
                inuse.Value = "Yes"
            elseif inuse.Value == "Yes" then
                GUI:TweenPosition(UDim2.new(0, -1500, 0, 0), "Out", "Elastic")
                inuse.Value = "No"
            end
            debounce = true
    end
end)
0
Why would you put them into 1? I don't believe it helps at all? lomo0987 250 — 10y
Ad

Answer this question