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: Would this work

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
29 Mar 2014 06:59 PM
Anybody?
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
29 Mar 2014 07:02 PM
key =+ "d"

what

i'm asian
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
29 Mar 2014 07:05 PM
OPPS. Typo
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
29 Mar 2014 07:09 PM
I don't believe mouse is accessible that way???
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
29 Mar 2014 07:12 PM
He's using PlayerMouse tho isn't he

i'm asian
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
29 Mar 2014 07:14 PM
No it woudln't
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
29 Mar 2014 07:16 PM
Just tell me, would it work (other then my typo =+)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
29 Mar 2014 07:16 PM
Still no
Report Abuse
jode6543 is not online. 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 is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
30 Mar 2014 12:22 PM
just use my script,and put it in startergui
no scripts needed other than that
Report Abuse
cntkillme is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
30 Mar 2014 12:29 PM
Yes I know I forgot to define p!
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
30 Mar 2014 12:30 PM
And made a typo.
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