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: Roblox Vehicles

Previous Thread :: Next Thread 
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 01:18 PM
I wanted to adapt a vehicle I made so that it runs on "battery" similar to that off a WIJ weapon where you touch to recharge to full 100 battery.
It will start off with 100 battery, and as you continuously drive about, the battery depletes.
How would I do this? like to make it deplete etc? Not too sure.
Also once it has reached 0 battery, the vehicle doesn't move any more; maybe changing the value of the throttle to 0 or something.
I also wanted to link this into a GUI, but I can do that I think.
Just wondering how to make it deplete and stop the car?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 01:36 PM
My explanation is quite confusing haha x3
Basically I want the textlabel number to deplete every time the vehicle moves. Once the text value hits = "0" then the car stops moving unless you drive into a charge point which I'll sort out.
Report Abuse
buddy249950 is not online. buddy249950
Joined: 30 Jun 2016
Total Posts: 3536
09 May 2013 02:07 PM
Use a for loop
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 02:27 PM
For what?
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
09 May 2013 02:32 PM
while wait() do
Battery = Battery - 1
wait(5)
end

This is an example.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 02:47 PM
Oh but how would that minus from the text label text itself? :p
Sorry really confused :c
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
09 May 2013 03:01 PM
The trick would be to basically have the text label watch a value. Out an intValue in somewhere

This script should go into the text label
BatteryValue = (You're Value)
TextLabel = script.Parent

function onChanged()
TextLabel.Text = Battery.Value
end

Battery.Changed:connect(onChanged)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 03:12 PM
Oh true, so an intValue will need to be placed into the text label.
So the IntValue is the actual figure changing rather than the text label!
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 03:19 PM
battery = script.Parent
function onChanged()
battery.Text = battery.Batt.Value
end

Battery.Changed:connect(onChanged)

How about this?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 03:34 PM
Would that work? to display the intValue in the text label?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 03:47 PM
Ah it doesn't seem to work? any help?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
09 May 2013 03:49 PM
This is the error displayed:
21:48:25.671 - Players.Player1.PlayerGui.GUI.Frame.FrameB.Battery.Script:6: attempt to index global 'Battery' (a nil value)
21:48:25.671 - Script "Players.Player1.PlayerGui.GUI.Frame.FrameB.Battery.Script", Line 6
21:48:25.671 - stack end
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
09 May 2013 03:49 PM
IntValues do not have text. It's battery.Value.

You need to link the IntValue to the vehicles. The IntValue is the Battery. Once you sit in the Vehicle, You're Character is linked to the Vehicle, thus allowing you to Link your Player to the vehicle, and your PlayerGui.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
09 May 2013 03:50 PM
In Lua, battery ~= Battery. They are two completely different ideas as Lua is case-sensitive.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 03:16 AM
Right I'm very confused, how would I make the IntValue display in the text?
Report Abuse
HD188753 is not online. HD188753
Joined: 13 Jun 2012
Total Posts: 5021
10 May 2013 06:20 AM
Textlabel.Text = "Battery at " .. Intvalue .. "%"
Report Abuse
HD188753 is not online. HD188753
Joined: 13 Jun 2012
Total Posts: 5021
10 May 2013 06:21 AM
Oops.
Should be intvalue.Value
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 11:46 AM
So it should be this:

battery = script.Parent
function onChanged()
battery.Text = "Battery at"..intvalue.Value.."
end

Battery.Changed:connect(onChanged)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 11:55 AM
Still doesn't work qq
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 12:05 PM
This is the script:
textlabel = script.Parent
intvalue = script.Parent.intvalue
function onChanged()
textlabel.Text = "" ..intvalue.Value.. "%"
end

intvalue.Changed:connect(onChanged)
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
10 May 2013 12:29 PM

function onChanged()
textlabel = script.Parent
intvalue = script.Parent.intvalue
function onChanged()
textlabel.Text = (invalue.Value)
end

intvalue.Changed:connect(onChanged)
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
10 May 2013 12:30 PM
Whoops, added an extra function. Ignore the on on top.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 12:32 PM
Ignore the one on top? Or the one within the script lines?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
10 May 2013 12:35 PM
Hm still doesn't seem to be working.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
10 May 2013 12:36 PM
Where are your Variables? The script is fine.

What is your Output reading? We need more then just, it doesn't work.
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