AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 03 Apr 2015 02:53 PM |
datastore:GetAsync("Position") -- Returns something like "50,10,20" for example
How can I convert this into string, so I can reposition the character based on their last visit?
...Torso.CFrame = CFrame.new(ds:GetAsync("Position"))
Output: Vector3 expected, got string
I have to use cframe because that repositions the whole character, while position doesn't. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 02:59 PM |
Could do the following:
Save each axis as it's own number Read up on string manipulation and figure it out |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
|
| 03 Apr 2015 02:59 PM |
how about.
Torso.CFrame = CFrame.new(tonumber(ds:GetAsync("Position"))) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:00 PM |
| You don't understand that tonumber can only make a string with NUMBERS a number. |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
|
| 03 Apr 2015 03:01 PM |
| I suggest that save everything not only CFrame.p if i was player when i rejoin game i would like to see my last rotation too |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 03:02 PM |
@dark, lemme get dis str8
le~ ',' can't b converted 2 a numbr
wh0 would've fawt dat sumfing clearly not being the following
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, .
could not = a number
xddd |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:04 PM |
| Don't know what that was for, Anime thought otherwise. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:05 PM |
If stuido was working I can woop you up a string to position converter
~Commands? Commands. www.roblox.com/Admin-item?id=232183441 |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 03 Apr 2015 03:06 PM |
@darkmist
I already read up on string manipulation before posting. Please, don't just refer people to it. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 03:08 PM |
| @Mr, I take it you would simply use string.find() and use dem %' signs |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:11 PM |
local nums ={} for x in string.gmatch(msg, "%d") do table.insert(nums,x) end local pos = Vector3.new(nums[1],nums[2],nums[3])
%d might be wrong http://wiki.roblox.com/index.php?title=String_patterns#string.match
~Commands? Commands. www.roblox.com/Admin-item?id=232183441 |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:13 PM |
The position is a Vector3. You may need to break it up; I'll show an example below.
Let's say you have the position myVector = (1, 2, 3) You can split this into the 3 coordinates (x, y, z). myVector.x == 1 myVector.y == 2 myVector.z == 3
Here's where your error comes in. You're passing a string as the argument, but it needs a Vector3 instance. You can create a position with Vector3.new(myVector.x, myVector.y, myVector.z) -- assuming your original value was a vector.
However, should the value be a string initially, you're going to have to do some magic. I don't use Lua, but I may be able to help. From the lua-users wiki, I was able to arrive at the "split" operator.
It goes something like this:
split("a,b,c", ",")
and returns this:
{"a", "b", "c"}
This should be an array, and can be referenced as such. Assuming your "50,10,20" example is how they are formatted, you can merely use the string in the split operator with a comma.
positionArray = split(positionValue, ",") newPosition = Vector3.new(positionArray[1], positionArray[2], positionArray[3])
This is not a pretty solution, but it should work. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 03:15 PM |
| If the split() operator is not available in ROBLOX-based Lua, you will need to use MrJoeyJoeJoey's suggestion to find matches in the string. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 03:16 PM |
ye split() r nawt here m8, dat wood've been a gr00vy feature
;-;-;-;-; |
|
|
| Report Abuse |
|
|