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: not working

Previous Thread :: Next Thread 
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
29 Nov 2015 03:12 PM
length = 1

wait(1)

start = coroutine.create(function()
for i = 9, 0, -1 do
for j = 59, 0, -1 do
if j > 9 then
script.Parent.Text = i .. ":" .. j
else
script.Parent.Text = i .. ":0" .. j
end
wait(length)
end
end

for i = 1, 2 do
script.Parent.Font = "SourceSansBold"
wait(0.5)
script.Parent.Font = "SourceSans"
wait(0.5)
end
end)

coroutine.resume(start)

script.Parent.Parent.SpeedTimeGui.MouseButton1Down:connect(function()
length = 0.05
coroutine.yield(start)
coroutine.resume(start)
end)

script.Parent.Parent.SpeedTimeGui.MouseButton1Up:connect(function()
length = 1
coroutine.yield(start)
coroutine.resume(start)
end)

All of that works until I stop clicking the button. The time starts going up at increments of like 3 and gets worse if I keep clicking

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
29 Nov 2015 04:39 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
30 Nov 2015 08:25 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
01 Dec 2015 07:37 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
02 Dec 2015 06:11 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
03 Dec 2015 09:09 PM
bump

This is advertising.
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
03 Dec 2015 10:09 PM
Never understood coroutines, cant help here :/
But what is happening is that a function is being called and connected multiple times, everytime you click it, it connects a function, and so when you click it again, it keeps the previous function and so over and over. But like I said, if that isnt it then blame it in my little knowledge on coroutines.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
04 Dec 2015 06:33 PM
I would expect yielding the coroutine to do what yield actually means, and resuming it would do what resume actually means.

This is advertising.
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
04 Dec 2015 07:41 PM
Looked a bit more into it, resuming it re runs the code I believe. Thats how it works, but it COroutines with the previous one, stacking the effect.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
04 Dec 2015 07:55 PM
I was thinking about if that was the cause. How would I go about preventing that?

This is advertising.
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
04 Dec 2015 09:43 PM
Ending a function, disconnecting it, breaking it. Any of those should work.
Report Abuse
hkep is not online. hkep
Joined: 19 Jul 2014
Total Posts: 550
04 Dec 2015 09:49 PM
add this

local function Start(Break)

-- check if break[1] == true

end;

local Current = {false};

coroutine.wrap(Start)(Current);

onDown function()
Current[1] = true
Current = {false}
coroutine.wrap(Start)(Current)
end
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
04 Dec 2015 09:57 PM
^
That would call an error most likely, given as you are trying to wrap a coroutine with 2 arguments, or it could still be I dont understand coroutines.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 Dec 2015 09:58 PM
It's the latter. He is wrapping the function, and then calling the wrapped function.
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
04 Dec 2015 09:59 PM
And just a shot in the dark here, but is this being used in a time related function? As in a clock? Given you can see
"script.Parent.Text = i .. ":" .. j
else
script.Parent.Text = i .. ":0" .. j"
Which looks like its trying to format it in a clock-like manner.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 08:37 AM
yes, when I hold down left click on a button I want the timer to speed up but when I release I want it to go back to normal

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 02:08 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 06:36 PM
bump

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 07:47 PM
bump

This is advertising.
Report Abuse
wonderful72pike is online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
05 Dec 2015 07:49 PM
When the mouse button is pressed, connect a function that depends on a variable that's changed when the mouse button is released. That's how automatic guns work.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 07:50 PM
I'll try that

This is advertising.
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 09:02 PM
how would I change the length of time that the loop waits without iterating through the whole script again each time the mouse is brought down/released?

This is advertising.
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
05 Dec 2015 09:17 PM
length = 1

wait(1)

start = coroutine.create(function()
for i = 9, 0, -1 do
for j = 59, 0, -1 do
if j > 9 then
script.Parent.Text = i .. ":" .. j
else
script.Parent.Text = i .. ":0" .. j
end
wait(length)
end
end

for i = 1, 2 do
script.Parent.Font = "SourceSansBold"
wait(0.5)
script.Parent.Font = "SourceSans"
wait(0.5)
end
end)

coroutine.resume(start)

script.Parent.Parent.SpeedTimeGui.MouseButton1Down:connect(function()
length = 0.05
end)

script.Parent.Parent.SpeedTimeGui.MouseButton1Up:connect(function()
length = 1
end)
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
05 Dec 2015 09:19 PM
^ you wish

This is advertising.
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
05 Dec 2015 09:22 PM
What's wrong with that? It seems to do as you describe.

wait internally calls yield and schedules the thread to resume at a later time. What you are doing is resuming the thread early when you pick the button, which runs through the body again and wait() schedules the task an additional time. This creates the stacking effect thread is scheduled to resume multiple times within the stack.
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