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: Make it where a part cannot get past a certain distance?

Previous Thread :: Next Thread 
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 12:43 AM
Im making a script that you can click and drag bricks, but i dont want the bricks to get too far from the original clicked distance. How would I do use? Im trying to figure it out via magnitude, can I set an objects magnitude?


Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 12:45 AM
b


Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 12:52 AM
if (PlayerCharacter.Torso.Position - part.Position).magnitude > MaxDistance then
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 12:53 AM
I got that. Its just setting the parts distance after that. Do I just magnitude = MaxDistance?


Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 12:56 AM
hmm, no.. because they're readonly values if i remember.


Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 12:57 AM
"Do I just magnitude = MaxDistance?"

I think you want this:

MaxDistance = -- maximum distance the part can be set to

You don't have to define MaxDistance.
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:04 AM
I know what magnitude is, its just how do I make it like a rope constraint, bascially.


Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 01:07 AM
Whaddya mean?

Is it like 'if part is too far away then don't run code'?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:08 AM
use a rope constraint

that or get the offset it is from the other part and if the magnitude of the offset is higher than what you want, set it to the offset.lookVector*maxlength
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:14 AM
I got a script that allows players to pick up objects. If the brick gets too farther than the original distance the player picked it up, it simply wont go any farther. As if the part was attached via a rope to the player. And I cant use rope constrants because they are broken, unless I am using them wrong.


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:15 AM
"cant use rope constrants because they are broken"
??????
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:16 AM
I have the attachments, the rope constraint, ive been testing them out and they simply do not work. Ive done everything right with them, dont think I havent attempted to use them. That was my original plan. But its legit just, not working. I drag the brick too far, and it just lets it.


Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 01:16 AM
So isn't this what you need?

if (PlayerCharacter.Torso.Position - part.Position).magnitude < MaxDistance then -- I derped out a little on my first time posting this

It checks for the distance and if the distance is smaller than MaxDistance then your code runs.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:17 AM
you can just use a prismatic constraint to make it only move along a certain axis and then change the CFrame of the Attachment to change the rotation of the brick
and then use LimitsEnabled and change the min and max when moving it
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:17 AM
I already have that, I just dont know the code to run to make it where it wont go any farther. I can check it, i just cant fix it.


Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:22 AM
Aha, I fixed my Rope Constraint problem. Im going to use that. Thanks for the help guys, I appreciate it.


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:26 AM
Pretty sure prismatics also have a Servo Actuator Type so you can change the position of it

one problem is that the lower limit has to be a bit high because it can possibly reflect backwards or behind itself when it takes too much force
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:29 AM
*sigh* I've come across another problem, I'd like to do this myself beacuse I dont want to have to burden you guys again, but when you *tug* on the constraint, the player goes with it. Can I just make the CurrentDistance the same as the magnitude when the maximum magnitude is reached to solve this, or is CurrentDistance a readonly?


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:30 AM
>> "Pretty sure prismatics also have a Servo Actuator Type so you can change the position of it"[2]
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 01:31 AM
Does 'if (PlayerCharacter.Torso.Position - part.Position).magnitude < MaxDistance then' not work for you then?

I'm lost here.
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
31 Aug 2016 01:32 AM
he wants to limit the position, not be like "omg guess what its not in range"
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
31 Aug 2016 01:32 AM
My bad, was typing and didnt see it. Ill check it out.


Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Aug 2016 02:01 AM
if (Part.Position - Torso.Position).magnitude > MaxDistance then
Part.CFrame = CFrame.new(Torso.Position + (Part.Position - Torso.Position).unit * MaxDistance)
end
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
31 Aug 2016 01:35 PM
^

Something like that.
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