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

Making a script more efficient?

Asked by 9 years ago

Is there a more efficient way to execute this besides disabling and re-enabling the script?

local EnterButton = script.Parent.EnterButton
local XBox = tonumber(script.Parent.XBox.Text)
local YBox = tonumber(script.Parent.YBox.Text)
local ZBox = tonumber(script.Parent.ZBox.Text)

function move()
    script.Disabled = true
    script.Disabled = false
    workspace.Part11.CFrame = CFrame.new(XBox, YBox, ZBox)
    end

EnterButton.MouseButton1Down:connect(move)

0
Have you tried using a 'Debounce'? [http://wiki.roblox.com/index.php?title=Debounce] TheeDeathCaster 2368 — 9y
2
What do you mean by "efficient"? BlueTaslem 18071 — 9y
0
Or you could just add a repeat wait() until game.Workspace.Door11 EmergencyAlt2 50 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Move the variables at the beginning of the script into the function. That way, whenever the function is called, the variables are refreshed, like so:

local EnterButton = script.Parent.EnterButton

function move()
    local XBox = tonumber(script.Parent.XBox.Text)
    local YBox = tonumber(script.Parent.YBox.Text)
    local ZBox = tonumber(script.Parent.ZBox.Text)

    game.Workspace.Part11.CFrame = CFrame.new(XBox, YBox, ZBox)
end

EnterButton.MouseButton1Down:connect(move)

Hope this helped!

Ad

Answer this question