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
 

Simple problem/question

Previous Thread :: Next Thread 
skill24 is not online. skill24
Joined: 14 Jun 2009
Total Posts: 13608
08 Apr 2014 06:12 PM
As I'm trying to learn to script, I'm attempting to make a brick move upon being clicked, then move back to its initial position.
Here's what I've got so far:

p = script.Parent
function MoveBrick()
for i = 18, 28, 1 do
p.CFrame = CFrame.new(i,1.7,9)
wait()
end
for i = 28, 18, 1 do
p.CFrame = CFrame.new(i,1.7,9)
end
end
p.ClickDetector.MouseClick:connect(MoveBrick)

It works for the most part, however it does not return to its original position. When you click it it moves 10 studs, but it doesnt move back to its initial position. However, when you click it again, it starts at the very first position, and moves 10 studs. How do I fix this?
Report Abuse
skill24 is not online. skill24
Joined: 14 Jun 2009
Total Posts: 13608
08 Apr 2014 06:19 PM
Anyone?
Report Abuse
Yionee is not online. Yionee
Joined: 03 Oct 2010
Total Posts: 322
08 Apr 2014 06:23 PM
local Brick = script.Parent
local Enabled = true

function BrickMover()
if Enabled then
Enabled = false
end
for Int = 1, 10 do
Brick.CFrame = Brick.CFrame * CFrame.new(0, Int, 0)
end
for Int = 1, 10 do
Brick.CFrame = Brick.CFrame * CFrame.new(0, -Int, 0)
end
Enabled = true
end

Brick.ClickDetector.MouseClick:connect(BrickMover)
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
08 Apr 2014 06:23 PM
p = script.Parent
function MoveBrick()
for i = 18, 28, 1 do
p.CFrame = CFrame.new(i,1.7,9)
wait()
end
for i = 28, 18, -1 do
p.CFrame = CFrame.new(i,1.7,9)
end
end
p.ClickDetector.MouseClick:connect(MoveBrick)
Report Abuse
Yionee is not online. Yionee
Joined: 03 Oct 2010
Total Posts: 322
08 Apr 2014 06:25 PM
I didn't put waits in mine--have fun with that!
Report Abuse
skill24 is not online. skill24
Joined: 14 Jun 2009
Total Posts: 13608
08 Apr 2014 06:29 PM
neither worked for me
Report Abuse
TaaRt is not online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
08 Apr 2014 07:13 PM
Why don't you move relative to the brick its position?
for i = 1,10 do
brick.CFrame = brick.CFrame + Vector3.new(translation/10)
end
for i = 1,10 do
brick.CFrame = brick.CFrame + Vector3.new(-(translation/10))
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