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: Rotation

Previous Thread :: Next Thread 
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:18 PM
Script:
while true do --works fine
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2)
wait()
end

while true do --This part doesn't work
wait(60)
script.Parent.CFrame.Angles.new(0, 90, 0)
wait(60)
script.Parent.CFrame.Angles.new(0, 180, 0)
wait(60)
script.Parent.CFrame.Angles.new(0, 270, 0)
wait(60)
script.Parent.CFrame.Angles.new(0,0, 0)
end

I wish for it to turn a 90° Angle every 60 seconds, and yet it fails. It just goes strait forward as what the part that works does.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 May 2014 06:19 PM
The first loop will never end, put it all in 1 loop or use a coroutine. And that's not how you change the rotation.

For 90 degrees:
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0)

And so on
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:23 PM
Doesn't work.
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:24 PM
Though I also might now need help with that top part thanks to you pointing that out to me...
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:29 PM
Bump
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:32 PM
Bump2
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:39 PM
I tried changing it:
while true do
if script.Parent.CFrame.Angles(0, 0, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2)
wait()
end
if script.Parent.CFrame.Angles(0, 90, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(-0.2, 0, 0)
wait()
end
if script.Parent.CFrame.Angles(0, 180, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, 0.2)
wait()
end
if script.Parent.CFrame.Angles(0, 270, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0.2, 0, 0)
wait()
end
end
while true do
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0)
wait(60)
end
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:41 PM
Bump3
Report Abuse
awesom914 is not online. awesom914
Joined: 06 Mar 2011
Total Posts: 4222
12 May 2014 06:46 PM
Ugh... you just aren't doing it right. Use a coroutine!
Also instead of using a thousand if statements do
script.Parent.CFrame = script.Parent.CFrame * script.Parent.CFrame.Angles.new(0, math.pi/2, 0)
Report Abuse
awesom914 is not online. awesom914
Joined: 06 Mar 2011
Total Posts: 4222
12 May 2014 06:47 PM
Wait, I didn't look through it all. Ignore the last part. Still though, coroutine.
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
12 May 2014 06:50 PM
Any Simpler way?
Report Abuse
awesom914 is not online. awesom914
Joined: 06 Mar 2011
Total Posts: 4222
12 May 2014 06:56 PM
Simpler? Coroutine is simple.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
12 May 2014 06:58 PM
Two different scripts in the same brick is much easier.
"I've never had to use coroutines in my life" -BetterBe, Owner of RblxDev
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 May 2014 08:19 PM
LOL inb4loopholeandheusesdelayorspawnfunctionorheartbeatslashstepped

Anyway there is usually a way to avoid using multiple loop, the most common people don't use is the Changed event.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 May 2014 08:20 PM
Anyways, you're welcome.

coroutine.wrap(function()
while true do
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2)
wait()
end end)()

while true do --This part doesn't work
wait(60)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0)
wait(60)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi, 0)
wait(60)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, 3*math.pi/2, 0)
wait(60)
script.Parent.CFrame = CFrame.new(script.Parent.Position)
end

try that
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
13 May 2014 04:45 PM
Thanks, may need editing though.
Need it to move in the direction its facing.
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
13 May 2014 05:25 PM
Now I'm having this problem

coroutine.wrap(function()
while true do
if script.Parent.CFrame == CFrame.Angles.new(0, 0, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2)
wait()
end
while true do
if script.Parent.CFrame == CFrame.Angles.new(0, 90, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(-0,2, 0, 0)
wait()
end
while true do
if script.Parent.CFrame == CFrame.Angles.new(0, 180, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2)
wait()
end
while true do
if script.Parent.CFrame == CFrame.Angles.new(0, 270, 0) then
script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0,2, 0, 0)
wait()
end end)()

while true do
wait(10)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0)
wait(10)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi, 0)
wait(10)
script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, 3*math.pi/2, 0)
wait(10)
script.Parent.CFrame = CFrame.new(script.Parent.Position)
end

Will not move the direction it is facing.
Report Abuse
Olama5 is not online. Olama5
Joined: 31 Jan 2010
Total Posts: 2827
13 May 2014 06:00 PM
Bump.1
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