How to make texbox convert into vector3 values?

So basically, I am making a coordinated based missile system, in which a player can enter coordinates into a textbox [GUI NOT A SURFACEGUI] and it will launch. The problem is, I have no idea how to make the textbox automatically convert into vector3 values.

pls help

1 Like

What would the input look like?

The simplest solution would be to just have 3 separate textboxes for each component, but if you really want to convert a string into a Vector3:

local function stringToVector3(vector : string)
	vector:gsub(" ", "")
	local x, y, z = table.unpack(string.split(vector, ","))
	return Vector3.new(x, y, z)
end
2 Likes

Just did that moments ago and saw your solution now. Thanks anyway.

Did you mean to replace whitespaces with commas?

No, it’s just so that the strings 5, 3, 2 and 5,3,2 both work.

1 Like