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: CFraming Troubles.

Previous Thread :: Next Thread 
huner2 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
20 Feb 2012 11:10 AM
This script is supposed to make this brick continue moving untill equalling another bricks position then moving the other way.But it just keeps going the one way and just passes through the brick.No output.How can I fix this?

MovingBrick = script.Parent
TargetBrick1 = script.Parent.Parent.Table.Wall1
TargetBrick2 = script.Parent.Parent.Table.Wall2
Moving1 = true
Moving2 =false

while true do
wait()
if Moving1 == true and Moving2 == false then
Moving1 = false
repeat
wait(1)
MovingBrick.CFrame = MovingBrick.CFrame * CFrame.new(1,0,0)
until MovingBrick.CFrame == TargetBrick1.Position
Moving2 = true
elseif Moving1 == false and Moving2 == true then
Moving2 = false
repeat wait(1)
MovingBrick.CFrame = MovingBrick.CFrame * CFrame.new(-1,0,0)
until MovingBrick.CFrame == TargetBrick2.Position
Moving1 = true
end
end
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
20 Feb 2012 11:13 AM
Use a loop without 'until'.

while true do
if position == second placement then
--move brick to first placement
end
if position == first placement then
--move brick to second placement
end
wait()
end

Ta da.
Report Abuse
huner2 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
20 Feb 2012 11:16 AM
I tried this already and it did not work and neither did the one I posted.
Report Abuse
asianpunk is not online. asianpunk
Joined: 15 Dec 2010
Total Posts: 150
20 Feb 2012 11:19 AM
MovingBrick = script.Parent
TargetBrick1 = script.Parent.Parent.Table.Wall1
TargetBrick2 = script.Parent.Parent.Table.Wall2
Moving1 = true
Moving2 =false

while true do
wait()
if Moving1 == true and Moving2 == false then
Moving1 = false
repeat
wait(1)
MovingBrick.CFrame = MovingBrick.CFrame * CFrame.new(1,0,0)
until MovingBrick.CFrame.p == TargetBrick1.Position
Moving2 = true
elseif Moving1 == false and Moving2 == true then
Moving2 = false
repeat wait(1)
MovingBrick.CFrame = MovingBrick.CFrame * CFrame.new(-1,0,0)
until MovingBrick.CFrame.p == TargetBrick2.Position
Moving1 = true
end
end

--[=[
You use a condition which test if CFrame = Postion it will return false for ever:
Use CFrame.p (return the Vector3 Position of the CFrame)
]=]
Report Abuse
huner2 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
20 Feb 2012 11:22 AM
It didn't help, it still did the same thing.
Report Abuse
huner2 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
20 Feb 2012 04:14 PM
Anyone else?
Report Abuse
xFortunato is not online. xFortunato
Joined: 25 Nov 2010
Total Posts: 865
20 Feb 2012 04:20 PM
This is happening because Roblox does not update fast enough to detect the exact moment the CFrames are exactly equal (they only get very close). You will have to add in some error, so if you are doing this on the x plane and the target brick is A and the moving brick is B....

while B.CFrame.x <= A.CFrame.x do
B.CFrame = B.CFrame + Vector3.new(1,0,0)
wait()
end
--when this while loop breaks it will have equalled or passed A's "x" position, so now set it in the opposite direction
while true do
B.CFrame = B.CFrame - Vector3.new(1,0,0)
wait()
end
Report Abuse
huner2 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
20 Feb 2012 04:33 PM
Oh,well thank you, but I also need to to reverse back the other way when it reaches the other position.
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