|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|