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 » Scripting Helpers
Home Search
 

Re: How to make an if and elseif work with position?

Previous Thread :: Next Thread 
mudkip99 is not online. 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
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
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 is not online. 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
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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