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: what is wrong with

Previous Thread :: Next Thread 
KingDoodleBob is not online. KingDoodleBob
Joined: 05 Aug 2009
Total Posts: 14092
16 Dec 2015 07:36 PM
while true do
wait(0.1)
if game.Workspace.Timer.Value == 0 then
script.Parent.Parent.ImageLabel.Visible = false
script.Parent.Parent.Time.Visible = false
else
script.Parent.Parent.ImageLabel.Visible = true
script.Parent.Parent.Time.Visible = true
end
end


while true do
wait()
script.Parent.Text = game.Workspace.Timer.Value
end


?
Report Abuse
rvox is not online. rvox
Joined: 18 Feb 2011
Total Posts: 5380
16 Dec 2015 07:38 PM
This doesn't work because the first loop never ends so the second loop will never be run

However, there is a better method to do all of this

workspace:WaitForChild("Timer")
workspace.Timer.Changed:connect(function()
if game.Workspace.Timer.Value == 0 then
script.Parent.Parent.ImageLabel.Visible = false
script.Parent.Parent.Time.Visible = false
else
script.Parent.Parent.ImageLabel.Visible = true
script.Parent.Parent.Time.Visible = true
end

script.Parent.Text = workspace.Timer.Value
end)
Report Abuse
KingDoodleBob is not online. KingDoodleBob
Joined: 05 Aug 2009
Total Posts: 14092
16 Dec 2015 07:41 PM
didn't work
Report Abuse
XIPokezIX is not online. XIPokezIX
Joined: 24 Sep 2015
Total Posts: 381
16 Dec 2015 07:44 PM
while true do
wait(0.1)
if game.Workspace.Timer.Value == 0 then
script.Parent.Parent.ImageLabel.Visible = false
script.Parent.Parent.Time.Visible = false
elseif game.Workspace.Timer.Value>0 then
script.Parent.Parent.ImageLabel.Visible = true
script.Parent.Parent.Time.Visible = true
end
end

spawn(function()
while true do
wait(0.1)
script.Parent.Text=game.Workspace.Timer.Value
end)
Report Abuse
PuzzleMeThis is not online. PuzzleMeThis
Joined: 15 Mar 2015
Total Posts: 41
16 Dec 2015 07:46 PM
rvoxs script only works if you have a NumberValue/IntValue object in your game.


~Cutting someone down at the knees doesn't make you any taller~
Report Abuse
PuzzleMeThis is not online. PuzzleMeThis
Joined: 15 Mar 2015
Total Posts: 41
16 Dec 2015 07:47 PM
Same with yours, so that may be your first concern, look for every Object named "Timer" in your workspace and see what shows!


~Cutting someone down at the knees doesn't make you any taller~
Report Abuse
rvox is not online. rvox
Joined: 18 Feb 2011
Total Posts: 5380
16 Dec 2015 07:49 PM
Well I'm assuming that there is such a thing in workspace, since it's in the original script

i do not think there's anything wrong with mine, post errors?
Report Abuse
KingDoodleBob is not online. KingDoodleBob
Joined: 05 Aug 2009
Total Posts: 14092
16 Dec 2015 08:28 PM
well, it's an intvalue named Timer and what's suppose to happen is it counts down from 60 when the round starts.

Idk the problem
Report Abuse
PuzzleMeThis is not online. PuzzleMeThis
Joined: 15 Mar 2015
Total Posts: 41
17 Dec 2015 03:28 PM
Let's break this down slowly:
While true loops never end, so anything that's after will never run, unless you break the loop using..well.. break in the loop.
So the first loop may very well be working, but we can't see it working. And because we want the loop that displays the timers value to always loop at a rate of 1/60th of a second (without a number wait() will always yield for a single frame, or 1/60th of a second). we need to have one loop. so what I would personally do is make the first while loop a function called "timerChange"
Secondly we need to Make a debounce so instead of it changing every frame, it will change in 0.1 seconds. This is done easily with a bool variable. At the top of your code place this:

local debounce = false

The third step is to implement this debounce. So cut out the code inside the timerChange function and place this there instead:

if debounce == false then
debounce = true
wait(0.1)
if game.Workspace.Timer.Value == 0 then
script.Parent.Parent.ImageLabel.Visible = false
script.Parent.Parent.Time.Visible = false
else
script.Parent.Parent.ImageLabel.Visible = true
script.Parent.Parent.Time.Visible = true
end
debounce = false
end

I'm assuming at this point another script lowers the timer, if so this is all you'll need, By the end your code will look like this:

--Beginning of the code

local debounce = false

function timeChange()
if debounce == false then
debounce = true
wait(0.1)
if game.Workspace.Timer.Value == 0 then
script.Parent.Parent.ImageLabel.Visible = false
script.Parent.Parent.Time.Visible = false
else
script.Parent.Parent.ImageLabel.Visible = true
script.Parent.Parent.Time.Visible = true
end
debounce = false
end
end

while true do
wait()
timeChange()
script.Parent.Text = game.Workspace.Timer.Value
end

--End of the code

~Cutting someone down at the knees doesn't make you any taller~
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