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: Am I doing something wrong or?

Previous Thread :: Next Thread 
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:37 PM
Ok so the BoolValue ClockRunning actually works, but the number ones don't change...
(This is in a GUI)



local ClockRunning = game.Workspace.GameScript.ClockRunning
local SValue = game.Workspace.GameScript.Seconds
local MValue = game.Workspace.GameScript.Minutes

game.Workspace.GameScript.Minutes.Value = 3
game.Workspace.GameScript.Seconds.Value = 0


timer = script.Parent
s = game.Workspace.GameScript.Seconds
m = game.Workspace.GameScript.Minutes

while ClockRunning.Value == true do
wait(1)
SValue.Value = SValue.Value - 1
if SValue.Value < 0 then
SValue.Value = 59
MValue.Value = MValue.Value - 1
end
end


while true do
if s.Value < 10 then
secondsString = "0".. s.Value
elseif s.Value >= 10 then
secondsString = s.Value
end
timer.Text = m.Value ..":".. secondsString
wait(1)
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Jan 2014 06:38 PM
The first loop will never end unless it is false.
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:40 PM
I know...
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:40 PM
Aaaaaaand I realised I can't do this because I can't have multiple players changing a single value in Workspace... nevermind
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
10 Jan 2014 06:40 PM
2 things

local SValue = game.Workspace.GameScript.Seconds
local MValue = game.Workspace.GameScript.Minutes
s = game.Workspace.GameScript.Seconds
m = game.Workspace.GameScript.Minutes

Why?

2nd, if you're using timer.Text to see if the values are working, well, lets just say you'll never see it change because THE CODE IS STUCK IN THE FIRST LOOP.
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:42 PM
Ok wait explain how...
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:45 PM
Oh wait I should mention hehe..

ClockRunning is false by default, and is later changed in the script as mentioned my orig post called "GameScript"
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Jan 2014 06:45 PM
Make sure it is changed before you create the loop
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
10 Jan 2014 06:46 PM
Well then. The script will never run the first loop because there is no reason the script should go back to the first loop after it is executed.
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 06:46 PM
So uh how can I fix that?...
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
10 Jan 2014 06:47 PM
Throw the entire thing into a while loop.
And also put the second loop as a function instead.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Jan 2014 06:48 PM
local ClockRunning = game.Workspace.GameScript.ClockRunning
local SValue = game.Workspace.GameScript.Seconds
local MValue = game.Workspace.GameScript.Minutes

game.Workspace.GameScript.Minutes.Value = 3
game.Workspace.GameScript.Seconds.Value = 0


timer = script.Parent
s = game.Workspace.GameScript.Seconds
m = game.Workspace.GameScript.Minutes

ClockRunning.Changed:connect(function(val)
while val == true do
wait(1)
SValue.Value = SValue.Value - 1
if SValue.Value < 0 then
SValue.Value = 59
MValue.Value = MValue.Value - 1
end
end)


while true do
if s.Value < 10 then
secondsString = "0".. s.Value
elseif s.Value >= 10 then
secondsString = s.Value
end
timer.Text = m.Value ..":".. secondsString
wait(1)
end
Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 07:19 PM
Ok quick question

Should "ClockRunning.Changed:connect(function(val)"
be "ClockRunning.Value.Changed..." since the definition of ClockRunning doesn't include ".Value"

Report Abuse
TheInnovative is not online. TheInnovative
Joined: 31 Dec 2008
Total Posts: 23486
10 Jan 2014 07:23 PM
Nevermind no you don't.
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