mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 19 Oct 2013 12:43 PM |
I am making a script right now, and I need an if and elseif work with position, the way I have it setup right now is something like this:
if script.Parent.Position ~= Vector3.new(0, 0, 0) then
elseif script.Parent.Position == Vector3.new(0,0,0) then
This is not working, and I can't find any info on how to get the position value to work with if/elseif. I would appreciate help with this. |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2013 12:47 PM |
| I've never heard of position being against the whole conditional statements... your problem is probably due to the fact that its extremely hard to get something in the exact position as something else, its just too exact. Your going to need to round your positions to make sure it will work within a stud at least, then you can nail it. But if that IS NOT the problem, and you can prove it, id try using CFrame instead. |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 19 Oct 2013 12:54 PM |
| The good thing about what I'm doing at the moment is that the position doesn't need to be exact, just within a certain area. How would I make it round to within a stud? |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2013 12:57 PM |
| within a certain area.. Well in that case youd have to use magnitude, is that what your doing? Because if you list off a million different "or"'s for the position, you still probably wont nail it. But rounding is easy. Do your if statement with the position.. then for the players torso position, you just want to add on either "math.ceil" or math.floor. Each rounds, floor rounds down, ceil rounds up |
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
|
| 19 Oct 2013 01:46 PM |
Or simply:
if script.Parent.Position.magnitude > 1 then
else
|
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
|
| 19 Oct 2013 01:47 PM |
BTW, if you're not using Vector3.new(0, 0, 0) then you have to do
if (script.Parent.Position-pos).magnitude > 1 then
else |
|
|
| Report Abuse |
|
|