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
 

how to limit rotation?

Previous Thread :: Next Thread 
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:27 PM
ok,well I want to make something rotate,but STOP rotating when it gets to a certain point..
heres what I tried(p.s Im using welds)
turret = script.Parent
w = Instance.new("Weld",turret)
w.Part0 = w.Parent
w.Part1 = w.Parent.Parent.MainPart
w.C0 = CFrame.new(0,-5,0)*CFrame.new(0,math.pi,0)
rotating = script.Parent.Direction
while wait(0.1) do
if rotating.Value == "right" and script.Parent.Rotation.X < 91 and script.Parent.Rotation.Z < 90 then
w.C0 = w.C0*CFrame.Angles(0,0.1,0)
elseif rotating.Value == "left" then
w.C0 = w.C0*CFrame.Angles(0,-0.1,0)
end
end
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:28 PM
but it keeps rotating past the point I want it to..
I only want it to make a 180 degree turn,and stop..but it goes the full 360 :\
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
21 Feb 2014 02:30 PM
Use the changed function of the cframe property or rotation? And trigger it to stop?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:30 PM
I know its only been 2 minutes..but Bump..its probably really simple :\
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:31 PM
@baheeg,im trying to make it so it only rotates to a certain point..
and ive like NEVER used .Changed events..:(
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:36 PM
-no one looking?..ok here goes..-
*sneaky bump
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:44 PM
bump again..:(
Report Abuse
velibor is not online. velibor
Joined: 24 Nov 2009
Total Posts: 1003
21 Feb 2014 02:47 PM
Use 'repeat until'
http://wiki.roblox.com/index.php?title=Repeat#The_.27repeat.27_Statement
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:50 PM
im using a "while wait(0.1) do" because I want it to ALWAYS rotate to the right if rotating.Value is equal to "right" and I want it to stop if it rotates to a certain point,but then rotate the other way it rotating.Value is equal to "left"..
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
21 Feb 2014 02:53 PM
never mind,i used a variable to control it:
turret = script.Parent
rotate = 0
w = Instance.new("Weld",turret)
w.Part0 = w.Parent
w.Part1 = w.Parent.Parent.MainPart
w.C0 = CFrame.new(0,-5,0)*CFrame.new(0,math.pi,0)
rotating = script.Parent.Direction
while wait(0.1) do
if rotating.Value == "right" and rotate<1.6 then
rotate = rotate+0.1
w.C0 = w.C0*CFrame.Angles(0,0.1,0)
elseif rotating.Value == "left" and rotate>-1.6 then
rotate = rotate-0.1
w.C0 = w.C0*CFrame.Angles(0,-0.1,0)
end
end
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