Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
-2

Making a script more efficient?

Asked by 5 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 2319 — 5y
2
What do you mean by "efficient"? BlueTaslem 17922 — 5y
0
Or you could just add a repeat wait() until game.Workspace.Door11 EmergencyAlt2 50 — 5y

1 answer

Log in to vote
0
Answered by 5 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