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

Making a script more efficient?

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)

3 comments

0

Have you tried using a 'Debounce'? [http://wiki.roblox.com/index.php?title=Debounce]

2

What do you mean by "efficient"?

0

Or you could just add a repeat wait() until game.Workspace.Door11

1 answer

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!

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