|
| 29 Mar 2014 06:33 PM |
Going to bed, had to get this down before I went to sleep.
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function() local Mouse = p:GetMouse() Mouse.KeyDown:connect(function(key) if key == "w" or key == "a" or key == "s" or key == "d" then KeyIsDown = true repeat wait(0.01) p.Character.Humanoid.WalkSpeed = p.Character.Humanoid.WalkSpeed + 0.5 until KeyIsDown == false end end) Mouse.KeyUp:connect(function(key) if key == "w" or key == "a" or key == "s" or key =+ "d" then KeyIsDown = false wait(0.01) p.Character.Humanoid.WalkSpeed = 16 end end) end) end)
I am not in front of a laptop right now... Would this work? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 29 Mar 2014 07:09 PM |
| I don't believe mouse is accessible that way??? |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2014 07:12 PM |
He's using PlayerMouse tho isn't he
i'm asian |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 29 Mar 2014 07:16 PM |
| Just tell me, would it work (other then my typo =+) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 29 Mar 2014 07:23 PM |
Works for me, though it is a little glitchy if you try to press more than one of the movement keys at once.
~Jode |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Mar 2014 07:25 PM |
Because you're probably testing it in solo. You can't get the player's mouse in a server-side script |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2014 07:31 PM |
It won't work Cuz :GetMouse() only works locally
(Won't work in server with ur code)
p = game.Players.LocalPlayer Max = 40 pressing = false m = p:GetMouse() m.KeyDown:connect(function(k) if k== "w" or k=="a" or k =="s" or k == "d" then pressing = true end end) m.KeyUp:connect(function() pressing = false end" while wait() do if pressing then c = p.Character if c.Humanoid.WalkSpeed < Max then c.Humanoid.WalkSpeed = c.Humanoid.WalkSpeed+0.5 end elseif c.Humanoid.WalkSpeed > 0 and not pressing then c.Humanoid.WalkSpeed = c.Humanoid.WalkSpeed-0.5 end end |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 04:11 AM |
Okay so...
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function() s = script:GetChildren()[1]:Clone() s.Parent = p.Backpack s.Disabled = false end) end)
Local script in that script (ONLY CHILD) local Mouse = p:GetMouse() Mouse.KeyDown:connect(function(key) if key == "w" or key == "a" or key == "s" or key == "d" then KeyIsDown = true repeat wait(0.01) p.Character.Humanoid.WalkSpeed = p.Character.Humanoid.WalkSpeed + 0.5 until KeyIsDown == false end end) Mouse.KeyUp:connect(function(key) if key == "w" or key == "a" or key == "s" or key =+ "d" then KeyIsDown = false wait(0.01) p.Character.Humanoid.WalkSpeed = 16 end end)
How about that version? |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 04:18 AM |
you'll need to fix your typo and define p again as it's a separate script, but yes.
#nerdsunited |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 04:21 AM |
Thanks, this is an epic "gaining speed script"
I could easily punch in a few more lines and have the gradually lose speed when they rest, but that's not very realistic. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Mar 2014 12:04 PM |
| It's still not going to work even if you put it in a local script using PlayerAdded |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 12:22 PM |
just use my script,and put it in startergui no scripts needed other than that |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Mar 2014 12:22 PM |
| Oops, I didn't see the separation between server and local script, yeah it should work |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Mar 2014 12:23 PM |
| but in that script, make p = Game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 12:29 PM |
| Yes I know I forgot to define p! |
|
|
| Report Abuse |
|
|
| |
|