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: BodyVelocity Acceleration Script, needs some help.

Previous Thread :: Next Thread 
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:10 PM
I have a script here that I'm trying to get to work. Script is located inside a part called "Engine." Here it is:

local VehicleSeat = script.Parent.Parent.HelmChair.HelmSeat
local Thruster = script.Parent.BodyVelocity

function Forward()
if Thruster.velocity.Z == 0 then
Thruster.velocity.Z + 100
wait(.1)

elseif Thruster.velocity.Z == 5000 then
Thruster.velocity.Z + 0
end
end
end



while true do

if VehicleSeat.Throttle == 1 then
Forward()

end
wait()
end


The point of this script is to increase the BodyVelocity's speed by 100 units every .1 seconds instead of jumping to 5000. Now here's the error:

Workspace.Model.Engine.Script:6: '=' expected near '+'

Okay, so I do what the error tells me to do. I add an '=' behind the '+' so it looks like this:

Thruster.velocity.Z =+ 100

Turns out, the studio doesn't like that either because it gives me the

Workspace.Model.Engine.Script:6: unexpected symbol near '+'

Well crap. Now what?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:14 PM
local VehicleSeat = script.Parent.Parent.HelmChair.HelmSeat
local Thruster = script.Parent.BodyVelocity

function Forward()
if Thruster.velocity.Z == 0 then
Thruster.velocity.Z = Thruster.velocity.Z + 100 --!
wait(.1)

elseif Thruster.velocity.Z == 5000 then --!
Thruster.velocity.Z = 0
end-- Possibly too many ends.
end
end



while true do

if VehicleSeat.Throttle == 1 then
Forward()

end
wait()
end
Report Abuse
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:19 PM
@MrChubbs
So far, I only got from your post to delete one end. It'd be helpful if you actually explained instead of leaving small hints that mean nothing.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:20 PM
The --! means I found the error and fixed it, basically what you were doing was just puttin a plus infront of the Z value as if to define a variable rather than what I think you meant to do which was to add onto the Z value, also you should compare the two scripts better, the changes were pretty obvious.
Report Abuse
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:23 PM
Oooh, I missed the changes. Whoops my bad.
Well, I made the changes, now the studio is complaining that

Z cannot be assigned to

And that's it.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:25 PM
I should have caught that Z issue,

local VehicleSeat = script.Parent.Parent.HelmChair.HelmSeat
local Thruster = script.Parent.BodyVelocity

function Forward()
if Thruster.velocity.Z == 0 then
Thruster.velocity.Z = Thruster.velocity.Z +Vector3.new(0,0,100) --!
wait(.1)

elseif Thruster.velocity.Z == 5000 then
Thruster.velocity = Thruster.velocity-Vector3.new(0,0,Thruster.velocity.Z) --!
end-- Possibly too many ends.
end
end



while true do

if VehicleSeat.Throttle == 1 then
Forward()

end
wait()
end
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:26 PM
Woops missed one more change.

local VehicleSeat = script.Parent.Parent.HelmChair.HelmSeat
local Thruster = script.Parent.BodyVelocity

function Forward()
if Thruster.velocity.Z == 0 then
Thruster.velocity = Thruster.velocity +Vector3.new(0,0,100) --!
wait(.1)
elseif Thruster.velocity.Z == 5000 then
Thruster.velocity = Thruster.velocity-Vector3.new(0,0,Thruster.velocity.Z) --!
end-- Possibly too many ends.
end
end



while true do

if VehicleSeat.Throttle == 1 then
Forward()

end
wait()
end
Report Abuse
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:30 PM
Sorry, I failed to mention the error popped up when Throttle == 1. Would that make a difference?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:31 PM
It popped up like that because the function was only activated when the throttle = 1, it makes no difference the issue was with me missing some obvious things.
Report Abuse
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:33 PM
It started working, but just maintains at 100. I'm sure I'll figure out how to get it to accelerate. Thanks for your help!
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:35 PM
Well initially the thrust value = 0 so the check goes and adds 100, now it is 100 so the check value is false and it doesn't add anything, what you should do is change the check to

if ZValueHere < MaxSpeedNumberHere then
Report Abuse
MarblesStudios is not online. MarblesStudios
Joined: 06 Mar 2010
Total Posts: 138
17 Oct 2012 01:40 PM
Beautiful! Thanks, bro!
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
17 Oct 2012 01:43 PM
PM me any time if you need more help.
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