Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 01:41 AM |
p = game.Players.LocalPlayer c = p.Character joint = c.Armor.Other repeat wait() until p p:GetMouse().KeyDown:connect(function(key) if key:lower() == "w" then script.Parent.Running.Value = true end end) p:GetMouse().KeyDown:connect(function(key) if key:lower() == "a" then script.Parent.Running.Value = true end end) p:GetMouse().KeyDown:connect(function(key) if key:lower() == "s" then script.Parent.Running.Value = true end end) p:GetMouse().KeyDown:connect(function(key) if key:lower() == "d" then script.Parent.Running.Value = true end end)
p:GetMouse().KeyUp:connect(function(key) if key:lower() == "w" then script.Parent.Running.Value = false end end) p:GetMouse().KeyUp:connect(function(key) if key:lower() == "a" then script.Parent.Running.Value = false end end) p:GetMouse().KeyUp:connect(function(key) if key:lower() == "s" then script.Parent.Running.Value = false end end) p:GetMouse().KeyUp:connect(function(key) if key:lower() == "d" then script.Parent.Running.Value = false end end)
while wait() do if script.Parent.Running.Value == false then c.Stand.Disabled = false c.Walk.Disabled = true elseif script.Parent.Running.Value == true then c.Stand.Disabled = true c.Walk.Disabled = false end end
So everything works except, if I'm pressing 2 keys at the same time, and lift one up, c.Stand.Disabled is set to false. How can I bypass that? |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
| |
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
| |
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
| |
|
|
| 24 Jun 2014 02:14 AM |
| I'm guessing you're trying to make a script enabled only when a character is moving? |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 02:15 AM |
| ^Yes, and when player stops is disables it. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 02:19 AM |
| http://wiki.roblox.com/index.php?title=Running_(Event) |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 02:20 AM |
^ I tried that but doesn't seem to work.. c = script.Parent.Parent.Character Humanoid = c.Humanoid Humanoid.Running:connect(function(speed)
if speed>0 then c.Walk.Disabled = false
else c.Stand.Disabled = false end end) while wait() do if c.Stand.Disabled == false then c.Walk.Disabled = true elseif c.Walk.Disabled == false then c.Stand.Disabled = true end end |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 02:26 AM |
Alright, so it fires when a humanoid starts running, and when it stops. So...
game.Workspace.Player.Humanoid.Running:connect(function(speed) if speed > 0 then print("Player is running") else print("Player has stopped") end end)
Now, we want to enable one script when one is walking, and disable it when one stops walking, so...
game.Workspace.Player.Humanoid.Running:connect(function(speed) if speed > 0 then print("Player is running") script1.Disabled = false else print("Player has stopped") script1.Disabled = true end end)
Does that explain it? |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 02:27 AM |
Yes so, c = script.Parent.Parent.Character Humanoid = c.Humanoid Humanoid.Running:connect(function(speed) if speed > 0 then c.Walk.Disabled = false c.Stand.Disabled = true else c.Stand.Disabled = false c.Walk.Disabled = true end end)
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 02:29 AM |
| Precisely. Just make sure c actually gets the character, and the character has the scripts "Walk" and "Stand," and that should do it. |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 02:31 AM |
No work c = script.Parent.Parent.Character repeat wait() until c Humanoid = c.Humanoid repeat wait() until Humanoid repeat wait() until c.Walk repeat wait() until c.Stand Humanoid.Running:connect(function(speed) if speed > 0 then c.Walk.Disabled = false c.Stand.Disabled = true else c.Stand.Disabled = false c.Walk.Disabled = true end end) |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 02:35 AM |
Try this:
repeat wait() until script.Parent.Parent.Character c = script.Parent.Parent.Character
repeat wait() until c:findFirstChild("Humanoid") Humanoid = c.Humanoid
repeat wait() until c:findFirstChild("Walk") repeat wait() until c:findFirstChild("Stand")
Humanoid.Running:connect(function(speed) if speed > 0 then
c.Walk.Disabled = false c.Stand.Disabled = true
else
c.Stand.Disabled = false c.Walk.Disabled = true
end end) |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
| |
|
|
| 24 Jun 2014 02:40 AM |
| What's wrong? Are any of the scripts being disabled/enabled? I tested the event and it works. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 02:42 AM |
| Bah, g2g to sleep. G'Luck, I'll try to see what I can do tomorrow. |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 02:43 AM |
Only Stand.Disabled works.. Walk doesn't change |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 11:40 AM |
| Bumping this so someone else can try to help. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 11:41 AM |
| so unorganized, not helping. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 11:52 AM |
| In my last script post, there was one event and one if statement. I'm not sure how much more organized it could be. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 11:55 AM |
You dont need to many KeyUp and KeyDown events.. just put
elseif key:lower() == blah then |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2014 11:58 AM |
Good grief why is everyone only reading the first post:
repeat wait() until script.Parent.Parent.Character c = script.Parent.Parent.Character
repeat wait() until c:findFirstChild("Humanoid") Humanoid = c.Humanoid
repeat wait() until c:findFirstChild("Walk") repeat wait() until c:findFirstChild("Stand")
Humanoid.Running:connect(function(speed) if speed > 0 then
c.Walk.Disabled = false c.Stand.Disabled = true
else
c.Stand.Disabled = false c.Walk.Disabled = true
end end)
|
|
|
| Report Abuse |
|
|
| |
|
legojoker
|
  |
| Joined: 23 Sep 2008 |
| Total Posts: 120 |
|
|
| 24 Jun 2014 12:36 PM |
| Btw for future reference Tynexx, have only 1 GetMouse event connection, and have an if then with several elseifs to test for other keys. Also, an easy way to solve your problem is to have a variable like local numKeys = 0 and every time a keydown is called make numKeys = numKeys+1 and every time a key comes up make numKeys = numKeys-1 and make it so it only disables itself when numKeys is updated to be = 0. Hope this helped. |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 24 Jun 2014 12:37 PM |
^ Oh, thank you :D I'll try it |
|
|
| Report Abuse |
|
|