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
 

repeat until help!

Previous Thread :: Next Thread 
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
18 May 2014 08:24 PM
Function: the script is suppose to play stepping sounds while the player steps.
Error: the script only plays the stepping sounds when the player walks once, when it's suppose to loop.

Output: none

Code:

local player = game.Players.LocalPlayer
local c = player.Character
local h = c.Humanoid

stop = false

h.Running:connect(function(speed)
if speed > 0 then
repeat
script.Step1:play()
wait(.25)
script.Step2:play()
wait(.25)
until stop == true
else
stop = true
end
end)

Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
18 May 2014 08:24 PM
repeat
script.Step1:play()
wait(.25)
script.Step2:play()
wait(.25)
until stop == true

This will never end because stop is never being changed to true inside the loop.
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
18 May 2014 08:26 PM
@Sensei

Then how do I make the loop stop when the player stops?
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
18 May 2014 08:28 PM
local player = game.Players.LocalPlayer
local c = player.Character
local h = c.Humanoid

stop = false

h.Running:connect(function(speed)
if speed > 0 then
repeat
h.Running:connect(function(sped)
if sped > 0 then
script.Step1:play()
wait(.25)
script.Step2:play()
wait(.25)
else
stop == true
end)
until stop == true
end
end)
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
18 May 2014 08:33 PM
@sensei

had an error, fix it to the code below
crashed.

code:
local player = game.Players.LocalPlayer
local c = player.Character
local h = c.Humanoid

stop = false

h.Running:connect(function(speed)
if speed > 0 then
repeat
h.Running:connect(function(sped)
if sped > 0 then
script.Step1:play()
wait(.25)
script.Step2:play()
wait(.25)
else
stop = true
end
end)
until stop == true
end
end)
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
18 May 2014 08:38 PM
local player = game.Players.LocalPlayer
local c = player.Character
local h = c.Humanoid

stop = false

function runrun(speed)
repeat
if speed > 0 then
script.Step1:play()
wait(.25)
script.Step2:play()
wait(.25)
else
stop = true
end
until stop == true
end

h.Running:connect(runrun)
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