truefire2
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
|
| 19 Jan 2014 12:45 PM |
Y = Workspace.Figure.Torso.BodyVelocity.velocity.Y
function touch(hit) hit.Parent.Torso.BodyVelocity.velocity = Vector3.new(0, Y, 0) end
script.Parent.Touched:connect(touch)
This is a moving target system. Basically, I wish for the figure to move up/down between two bricks. When it hit a brick, it goes back down. I have also made a Surface GUI so that the player can increase/decrease the speed to vary the level of challenge.
-------------- O / | \ / \
--------------
The problem is that the Value of Y always resets it to the original value of 2, even when the person has increased the speed. How do I stop it resetting to the original value?
Thank you for any help.
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 12:47 PM |
Try declaring 'Y' inside the function, rather than outside:
function touch(hit) Y = Workspace.Figure.Torso.BodyVelocity.velocity.Y hit.Parent.Torso.BodyVelocity.velocity = Vector3.new(0, Y, 0) end |
|
|
| Report Abuse |
|
|
truefire2
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
| |
|
truefire2
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
|
| 19 Jan 2014 01:10 PM |
Ok, I have another problem. When the figure hits the bottom brick, it doesn't bounce back. I thought because Y is a negative number, I could make it positive by adding - in front as two -- = a positive number.
function touch(hit) Y = Workspace.Figure.Torso.BodyVelocity.velocity.Y hit.Parent.Torso.BodyVelocity.velocity = Vector3.new(0, -Y, 0) end
script.Parent.Touched:connect(touch)
How do I fix this so when it touches the bottom brick, the velocity Y value because positive again? |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 01:23 PM |
| That's strange, it worked when I tested it. Did you make sure to put the script into both the parts that Torso will bounce between? |
|
|
| Report Abuse |
|
|
truefire2
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
| |
|
truefire2
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
| |
|