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: How to fix?

Previous Thread :: Next Thread 
truefire2 is not online. 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
BrainSqueezer is not online. BrainSqueezer
Joined: 19 Aug 2009
Total Posts: 432
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 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
19 Jan 2014 12:52 PM
Thank you.
Report Abuse
truefire2 is not online. 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
BrainSqueezer is not online. BrainSqueezer
Joined: 19 Aug 2009
Total Posts: 432
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 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
19 Jan 2014 01:41 PM
Yes.
Report Abuse
truefire2 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
19 Jan 2014 02:16 PM
bump
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