generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: convert string to vector3?

Previous Thread :: Next Thread 
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 05:54 PM
How would I turn
"0, 0, 0"
into
Vector3.new(0, 0, 0)

assuming I don't know that "0, 0, 0" is exactly "0, 0, 0" relative to things such as the length of the string, etc
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
01 Jan 2016 06:01 PM
I forgot
Report Abuse
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 06:02 PM
"I forgot"

ikr
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
01 Jan 2016 06:04 PM
I can get you the first coordinate

local x = stng:match("%d+")
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
01 Jan 2016 06:06 PM
print(string.match("0,0,0","%d+%,%d+%,%d+"))


AH HA

I was able to turn a string, into a string..
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:07 PM
print(Vector3.new("0, 0, 0"))
Report Abuse
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 06:07 PM
"print(Vector3.new("0, 0, 0"))"

gtfo
Report Abuse
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 06:09 PM
@joey

that's still a string though
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
01 Jan 2016 06:10 PM
local x = stng:match("%d+")
stng = stng:sub(#x,#stng)
local y = stng:match("%d+")
stng = stng:sub(#y,#stng)
local z = stng:match("%d+")
local vector = Vector3.new(tonumber(x),tonumber(y),tonumber(z))
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
01 Jan 2016 06:10 PM
local Coords = "0, 0, 0"
local X,Y,Z = Coords:match("^%s*([%d%.]-)%s*,%s*([%d%.]-)%s*,%s*([%d%.]-)%s*$")
print(X,Y,Z)

Also gets decimal numbers.
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:11 PM
it doesn't error :)
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
01 Jan 2016 06:11 PM
And if you want to turn it into Vector3:

local V3 = (tonumber(X), tonumber(Y), tonumber(Z))
Report Abuse
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 06:12 PM
"Try it before you judge, idiot."

leave you're not smart
Report Abuse
DermonDarble is not online. DermonDarble
Joined: 04 Jun 2015
Total Posts: 2576
01 Jan 2016 06:12 PM
local function StringToVector3(str)
local x, y, z = string.match(str, "(.+), (.+), (.+)")
return Vector3.new(tonumber(x), tonumber(y), tonumber(z))
end

/Domingo en fuego/
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:18 PM
lol says the one who can't script

local Table = {}
local String = "10, 10, 9"

for v in string.gmatch(String, "%d+") do
table.insert(Table, v)
end

game.Workspace.Part.Position = Vector3.new(Table[1], Table[2], Table[3])
Report Abuse
spunjebab is not online. spunjebab
Joined: 17 Oct 2015
Total Posts: 303
01 Jan 2016 06:20 PM
"local Table = {}
local String = "10, 10, 9"

for v in string.gmatch(String, "%d+") do
table.insert(Table, v)
end

game.Workspace.Part.Position = Vector3.new(Table[1], Table[2], Table[3])"

yeah sure keep talking urself up
no one cares ur not smart
question was answered, put ur ego away and gtfo
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:23 PM
lol im smarter than u 8 year old noob
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:24 PM
i made similar one to dermon, so i made a different one

im here to help you, you're not here to help me lol
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 06:43 PM
idk why but here:

local String = "10, 10, 9"
game.Workspace.Part.Position = Vector3.new(string.match(String, "(%d+), (%d+), (%d+)"))
Report Abuse
KAMIKAZEPOLO is not online. KAMIKAZEPOLO
Joined: 14 Mar 2012
Total Posts: 1049
01 Jan 2016 07:48 PM
vector3.new(tonumber('1'), tonumber('1'),tonumber('1'))
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
01 Jan 2016 07:52 PM
Why are you guys using complicated string stuff? ROBLOX automatically lets strings be used as numbers when possible:

local vec = "0, 0, 0"
local v3 = Vector3.new(vec)
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 08:19 PM
^ No.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Jan 2016 08:47 PM
Ugh a baby argument
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
01 Jan 2016 08:51 PM
^ stfu above op is savage
Report Abuse
BlueWizard12345 is not online. BlueWizard12345
Joined: 31 Mar 2012
Total Posts: 906
01 Jan 2016 09:05 PM
who tf are you talking about fish
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image