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 » Scripters
Home Search
 

Re: Why doesn't this work?

Previous Thread :: Next Thread 
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 02:05 PM
Why doesn't this script add to the value while its being pressed xD

on = false
function run()
on = true
end
function off()
on = false
end

script.Parent.MouseButton1Down:connect(run)
script.Parent.MouseButton1Up:connect(off)
while on == true do
script.Parent.Parent.TextLabel.kibarenergy.energy.Value = script.Parent.Parent.TextLabel.kibarenergy.energy.Value + 5
wait(0.1)
end
Report Abuse
FlyScript is not online. FlyScript
Joined: 05 Aug 2010
Total Posts: 2884
16 May 2015 02:36 PM
Because as soon as on == false the while loop breaks.

You need to loop and have an if statement in place to decide.

while wait() do
if condition then
--stuff
end
end
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
16 May 2015 02:39 PM
on = false
energy = script.Parent.Parent.TextLabel.kibarenergy.energy

function run()

on = true

while wait(0.1) and on do
energy.Value = (energy.Value + 5)
end
end

function off()
on = false
end

script.Parent.MouseButton1Down:connect(run)
script.Parent.MouseButton1Up:connect(off)
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 03:32 PM
didn't work but thanks
and fly can you explain that little bit better xD
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 May 2015 03:36 PM
local CAS = game:GetService("ContextActionService")
local on = false

function toggleOn(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
on = true
elseif inputState == Enum.UserInputState.End then
on = false
end
end

CAS:BindAction("toggleOn", toggleOn, false, Enum.KeyCode.A)

while true do
if on then
script.Parent.Parent.TextLabel.kibarenergy.energy.Value = script.Parent.Parent.TextLabel.kibarenergy.energy.Value + 5
end
wait(.1)
end
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 03:42 PM
that idea still didn't work but thanks anyway.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 May 2015 03:45 PM
The script itself works fine, the value just probably doesn't exist.
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 03:51 PM
No, the value does exist o.o here's the script its in...
energy = Instance.new("IntValue")
energy = 100
add = 1
while true do
script.Parent.Text = energy
if energy < 1000 then
energy = energy + 1
else
energy = 1000
end
if energy <= 0 then
energy = 1
end
wait(0.1)
end
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 04:01 PM
Okay I tried changing where the value is, instead of being inside the script its at script.energy instead of inside the code
but when I changed this code to work with that nothing in the code works :/


energy = Instance.new("IntValue")
energy = 100
add = 1
while true do
script.Parent.Text = energy
if energy < 1000 then
energy = energy + 1
else
energy = 1000
end
if energy <= 0 then
energy = 1
end
wait(0.1)
end
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 04:52 PM
b1
Report Abuse
Embolden is not online. Embolden
Joined: 02 May 2009
Total Posts: 148
16 May 2015 04:58 PM
Well script.Parent.Text = Energy is wrong...

You need to add "Energy"
Report Abuse
rockshe1000 is not online. rockshe1000
Joined: 26 May 2011
Total Posts: 547
16 May 2015 05:22 PM
Embolden, No that code I gave in the last post works perfectly fine, I was asking how do I use a value THATS not in the code (like instead>value into the script but not actually in the code) like use it for something inside the code, every time I try it does not work.
Report Abuse
Embolden is not online. Embolden
Joined: 02 May 2009
Total Posts: 148
16 May 2015 05:24 PM
Energy.Value = Energy.Value > 1

That sort?















Don't worry I'm new! <3
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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