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

Taking input from a GUI and positioning a brick?

Asked by 9 years ago

How would one go about taking a set position that a user entered into a GUI and having it position a brick at those coordinates?

2 answers

Log in to vote
1
Answered by 9 years ago

Have 3 textbox for X Y Z and then by creating a script such as:

EnterButton.MouseButton1Down:connect(function()
game.Workspace.INSERTNAMEOFBRICK.Position = CFrame.new(XBox, YBox, Zbox)
end)

Also make sure to have a TextButton for the Enter. By doing this you use CFrame to change the positions using Vector3 (Or CFrame). CFrame and Vector3 include a X,Y,Z. Entering the coordinates (X,Y,Z) you change the position.

0
Whenever I change the Text values in-game it doesn't update and the brick stays in the same spot. Blackbrick2896 0 — 9y
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Assuming you're going off of the Text property of the Gui then what you have to do is take the text, and convert it into a number using the tonumber method, and use the result as the arguments for the CFrame.

E.G.

local text = gui.Text
local num = tonumber(text)
local Cframe = CFrame.new(num)

workspace.Part.CFrame = Cframe

Answer this question