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: Two problems with this script. (easy)

Previous Thread :: Next Thread 
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:11 PM
1. Debounce will not work properly
2. "keydown" stays down forever after you press once

newspeed = 30
oldspeed = 16
player = game.Players.LocalPlayer
mouse = player:GetMouse()
keydown = false
stamina = script.Parent
debounce = false

mouse.KeyDown:connect(function(key)
debounce = true
if key == "q" then
keydown = true
if keydown == true then
player.Character.Humanoid.WalkSpeed = newspeed
stamina.Size = stamina.Size + UDim2.new(-0.01,0)
else
player.Character.Humanoid.WalkSpeed = oldspeed
stamina.Size = stamina.Size + UDim2.new(0,0)
wait(5)
debounce = false
end
end
end)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:14 PM
You have no condition checking against your debounce
You need to set your mousedown to false on mouseup
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:14 PM
Keydown, I meant. On keyup.
Bleh
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:16 PM
You have no condition checking against your debounce

??
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:18 PM
oh, but its still not working.

newspeed = 30
oldspeed = 16
player = game.Players.LocalPlayer
mouse = player:GetMouse()
keydown = false
stamina = script.Parent
debounce = false

mouse.KeyDown:connect(function(key)
if debounce == true then return end
debounce = true
if key == "q" then
keydown = true
if keydown == true then
player.Character.Humanoid.WalkSpeed = newspeed
stamina.Size = stamina.Size + UDim2.new(-0.01,0)
wait(1)
keydown = false
else
player.Character.Humanoid.WalkSpeed = oldspeed
stamina.Size = stamina.Size + UDim2.new(0,0)
wait(5)
debounce = false
end
end
end)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:20 PM
Your entire if keydown statement is obsolete
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:23 PM
How? Could you just try fixing the scripts?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:28 PM
Nope, because I'm on my tablet and not in the mood for being helpful.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:31 PM
Oh, alright :/

But could you tell me where I went wrong? I dont understand
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:36 PM
Bump
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:37 PM
Keydown is gauranteed to be true by the time the if statement comes. This makes the else block obsolete, and the entire statement.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:41 PM
okay, now whats wrong. same problems

mouse.KeyDown:connect(function(key)
if debounce == true then return end
debounce = true
if key == "q" then
if keydown == false then
keydown = true
player.Character.Humanoid.WalkSpeed = newspeed
stamina.Size = stamina.Size + UDim2.new(-0.01,0)
wait(1)
keydown = false
wait(5)
debounce = false
end
end
end)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:45 PM
Your if keydown statement is redundant.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:50 PM
How though :(
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:51 PM
Your debounce stole its job.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 07:55 PM
still wont work:

newspeed = 30
oldspeed = 16
player = game.Players.LocalPlayer
mouse = player:GetMouse()
stamina = script.Parent
debounce = false

mouse.KeyDown:connect(function(key)
if debounce == true then return end
debounce = true
if key == "q" then
player.Character.Humanoid.WalkSpeed = newspeed
stamina.Size = stamina.Size + UDim2.new(-0.01,0)
wait(5)
debounce = false
end
end)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
28 Oct 2014 07:58 PM
UDim2s take 4 values I thought?

stamina.Size = stamina.Size + UDim2.new(-0.01, 0, 0, 0)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 07:58 PM
You never set your walkspeed back to oldspeed
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
28 Oct 2014 07:59 PM
Also, you are turning debounce on if debounce is off, but only turning debounce back off if the key was Q. That means that if any other key is pressed, it turns debounce on permanently.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
28 Oct 2014 08:13 PM
I give up :/
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Oct 2014 08:15 PM
XD
You should have done it UNIX style.
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
29 Oct 2014 02:47 PM
ill try again. help?
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
29 Oct 2014 03:25 PM
...
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Oct 2014 03:37 PM
"Also, you are turning debounce on if debounce is off, but only turning debounce back off if the key was Q. That means that if any other key is pressed, it turns debounce on permanently." -JarodOfOrbiter
Report Abuse
FlameYeti is not online. FlameYeti
Joined: 14 Jan 2009
Total Posts: 22158
29 Oct 2014 03:43 PM
Okay, now still two problems. If you press down Q, then you only sprint for a second and then the GUI only goes down once even if you hold Q down for 20 seconds or more.

newspeed = 30
oldspeed = 16
player = game.Players.LocalPlayer
mouse = player:GetMouse()
staminabutton = script.Parent
stamina = 0
keydown = false

mouse.KeyDown:connect(function(key)
if key == "q" then
keydown = true
while keydown == true do
player.Character.Humanoid.WalkSpeed = newspeed
staminabutton.Size = staminabutton.Size + UDim2.new(-0.01, 0)
wait(1)
player.Character.Humanoid.WalkSpeed = oldspeed
keydown = false
end
end
end)
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