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: gah,trying to rotate a part on axis like thing..

Previous Thread :: Next Thread 
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:21 PM
sorry if my grammar on the tile stunk but..im trying to make like,an "orb"
(yknow,it goes around in a circle around me)

ive been trying and trying,but for the life of me,i cant figure it out >_<
what I have so far:

me = "Player1"
local orb = Instance.new("Part",Workspace)
local controller = game.Players[me]
local controlTool = Instance.new("Tool",controller.Backpack)
local pos = Instance.new("BodyPosition",orb)
orb.CFrame = controller.Character.Head.CFrame*CFrame.new(0,0,-10)
orb.Anchored = true
orb.CanCollide = false
pos.position = (controller.Character.Head.CFrame*CFrame.new(0,0,-3)).p
orb.Anchored = false
local loopPosition = coroutine.wrap(function(obj)
while wait() do
cf = (controller.Character.Head.CFrame*CFrame.new(0,0,10))
for i=1,270 do
cf = cf*CFrame.Angles(0,math.rad(1),0)
cf = cf*CFrame.new(0,0,-0.1)
newcf = (controller.Character.Head.CFrame*CFrame.new(0,0,10).p)
obj.BodyPosition.position = (newcf+cf.p)
wait()
end
end
end)
loopPosition(orb)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:26 PM
bump
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:32 PM
bump..
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
17 Apr 2014 02:33 PM
orb.Anchored = true <--
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:34 PM
@rofl

I wish ppl would look at the full script..

orb.Anchored = true--anchor
orb.CanCollide = false--not collide
pos.position = (controller.Character.Head.CFrame*CFrame.new(0,0,-3)).p--set pos
orb.Anchored = false--UNANCHOR HERE..
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
17 Apr 2014 02:35 PM
Can you tell us what the problem is, then?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:37 PM
theres no errors,the script just doesn't do what im trying to do..

its supposed to rotate around me..

wow,i do wish ppl would read what I post,not just read one line and be like

0mgeee u cant scr1pttt :3

sigh..
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 02:38 PM
path orb takes
__
(me)
""
the ()'s and __'s and ""'s are lines

so basicly,it rotates on axis,around me,a few studs forwards
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
17 Apr 2014 02:45 PM
while wait() do
cf = (controller.Character.Head.CFrame*CFrame.new(0,0,10))
for i=1,270 do
cf = cf*CFrame.Angles(0,math.rad(1),0)
cf = cf*CFrame.new(0,0,-0.1)
newcf = (controller.Character.Head.CFrame*CFrame.new(0,0,10).p)
obj.BodyPosition.position = (newcf+cf.p)
wait()
end
end

can all be changed to


local count = 0
while wait() do
count = count + 1
cf = (controller.Character.Head.CFrame * CFrame.Angles(0,0.1*count,0) * CFrame.new(0,0,10)
obj.BodyPosition.position = cf.p
wait()
end
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
17 Apr 2014 02:58 PM
or, even better:

speed = 1 -- or whatever
while true do
for i=1, 360 do
cf = (controller.Character.Head.CFrame * CFrame.Angles(0,speed*i*math.pi/180,0) * CFrame.new(0,0,10)
obj.BodyPosition.position = cf.p
wait()
end
end




Think what order you multiply CFrames in:

Imagine X is your head, and Y is the orb

What you did was put Y 10 studs in front of X, and then rotated X

while what you should have done was

rotate Y, then put X 10 studs in front.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
17 Apr 2014 03:55 PM
I edited a wiki script a while back, it really helped me. Feel free to incorporate in your script.

local angle = 0

while wait() do
script.Parent.CFrame = CFrame.new(target.Position) --Start at the position of the part
* CFrame.Angles(0, angle, 0) --Rotate by the angle
* CFrame.new(0, 0, -5) --Move the part backwards 5 units on the Z axis.
angle = angle + math.rad(10)
end

When life gives you lemons... BURN HIS HOUSE DOWN! >:D
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
17 Apr 2014 06:35 PM
@Rofl

thx so much :P
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Apr 2014 06:38 PM
'* CFrame.new(0, 0, -5) --Move the part backwards 5 units on the Z axis.'
That's a terrible idea, you aren't offsetting it correctly.
Use 0, 0, 5
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