|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 16 May 2015 03:32 PM |
didn't work but thanks and fly can you explain that little bit better xD |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 16 May 2015 03:42 PM |
| that idea still didn't work but thanks anyway. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 03:45 PM |
| The script itself works fine, the value just probably doesn't exist. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|