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

Numbers not registering?

Asked by 9 years ago

So this script basically grabs the Text values (which start out blank) and teleports the brick to those XYZ coordinates. However, whenever I enter a value In-Game it doesn't register it and the brick goes to 0, 0, 0. How would I fix this?

local EnterButton = script.Parent.EnterButton
local XBox = script.Parent.XBox.Text
local YBox = script.Parent.YBox.Text
local ZBox = script.Parent.ZBox.Text

EnterButton.MouseButton1Down:connect(function()
game.Workspace.Part11.CFrame = CFrame.new(XBox, YBox, ZBox)
end)
1
Please dont ask the same question twice. Did you even try the answer I gave you? BSIncorporated 640 — 9y
0
You didn't give me an answer @BSincorperated Blackbrick2896 0 — 9y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

You need to use the tonumber method!

Since the Text property of a gui holds a string, and a CFrame takes numbers you have to convert the strings to numbers using tonumber.

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)

EnterButton.MouseButton1Down:connect(function()
    workspace.Part11.CFrame = CFrame.new(XBox, YBox, ZBox)
end)
0
It's not working for some reason. Blackbrick2896 0 — 9y
Ad

Answer this question