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 » Game Design
Home Search
 

Re: Help with making a key down change someone's speed

Previous Thread :: Next Thread 
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 05:41 PM
local EternalSouI = Game.Players.LocalPlayer; --The player that can use the key down
local Mouse = Player:GetMouse();

Mouse.KeyDown:connect(function(Key)
if (Key:lower() == "x") then --The key to activate
if (EternalSouI.Character ~= nil) then
game.Workspace.EternalSouI.Humanoid.Speed = 25();
end
end
end)






I'm trying to make it that one player can press a certain key and it changes their character's walkspeed. I'm just asking for some help I'm not asking someone to make it for me.

Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
24 May 2015 06:02 PM
if Key == "x" then
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 06:10 PM
local EternalSouI = Game.Players.LocalPlayer; --The player that can use the keydown
local Mouse = Player:GetMouse();

Mouse.KeyDown:connect(function(Key)
if Key == "x") then --The key to activate
if (EternalSouI.Character ~= nil) then
game.Workspace.EternalSouI.Humanoid.Speed = 25();--Changes the player's speed
end
end
end)




Was it that? Because it didn't work.
Report Abuse
GhostSailor is not online. GhostSailor
Joined: 02 Jul 2010
Total Posts: 1913
24 May 2015 06:13 PM
local ply = game.Players.LocalPlayer;
local Mouse = Player:GetMouse();

Mouse.KeyDown:connect(function(Key)
if Key == "x") then
if (ply.Character ~= nil) then
ply.Character.Humanoid.Speed = 25()
end
end
end)

Lord of all things, breaded and unbreaded.
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 06:22 PM
local EternalSouI = game.Players.LocalPlayer;
local Mouse = Player:GetMouse();

Mouse.KeyDown:connect(function(Key)
if Key == "x") then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.Speed = 25()
end
end
end)




It still didn't work. I first didn't changed the "ply" and it still did not work. I did press x.
Report Abuse
GhostSailor is not online. GhostSailor
Joined: 02 Jul 2010
Total Posts: 1913
24 May 2015 06:24 PM
Get rid of the stray parenthesis, sorry I missed that.

Lord of all things, breaded and unbreaded.
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 06:32 PM
local EternalSouI = game.Players.LocalPlayer;
local Mouse = Player:GetMouse();

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.Speed = 25
end
end
end)






It didn't work. I put a "()" next to the 25 first then when it didn't work, I removed it. But it still didn't work.
Report Abuse
GhostSailor is not online. GhostSailor
Joined: 02 Jul 2010
Total Posts: 1913
24 May 2015 06:39 PM
local ply = game.Players.LocalPlayer
local Mouse = ply:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (ply.Character ~= nil) then
ply.Character.Humanoid.Speed = 25
end
end
end)

Lord of all things, breaded and unbreaded.
Report Abuse
GhostSailor is not online. GhostSailor
Joined: 02 Jul 2010
Total Posts: 1913
24 May 2015 06:39 PM
local ply = game.Players.LocalPlayer
local Mouse = ply:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (ply.Character ~= nil) then
ply.Character.Humanoid.WalkSpeed = 25
end
end
end)

Rather

Lord of all things, breaded and unbreaded.
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 06:50 PM
On the "ply" do I replace it the name of the player I only want to be able to change their speed when they press the key?
Report Abuse
PraetorianTheGod is not online. PraetorianTheGod
Joined: 02 May 2014
Total Posts: 814
24 May 2015 07:05 PM
it's not speed it's walkspeed
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 07:13 PM
local EternalSouI = game.Players.LocalPlayer
local Mouse = EternalSouI:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.WalkSpeed = 25
end
end
end)




It did work but, I tried it on my ALT and it also worked for my ALT..
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
24 May 2015 07:19 PM
Remote Events and UserInputService.
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 07:25 PM
^ What?
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
24 May 2015 07:35 PM
It works for other people because EternalSoul is listed as an localplayer meaning the one pressing the key.



=volty=
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
24 May 2015 07:45 PM
So this is what you'd do if you want it to work for you only.

local EternalSouI = game.Workspace:WaitForChild("EternalSouI")
local Mouse = EternalSouI:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.WalkSpeed = 25
end
end
end)



=volty=
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 07:53 PM
local EternalSouI = game.Workspace:WaitForChild("EternalSouI")
local Mouse = EternalSouI:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.WalkSpeed = 25
end
end
end)




So I put it in and it didn't even change my walkspeed.
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
24 May 2015 07:58 PM
It probably only works in the server, not in studio ok



=volty=
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 08:06 PM
I know I tried it in the game not test mode and it didn't change my walkspeed.
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
24 May 2015 08:09 PM
local player = game.Players.LocalPlayer
local EternalSouI = game.Workspace:WaitForChild("EternalSouI")
local Mouse = player:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.WalkSpeed = 25
end
end
end)



=volty=
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 08:13 PM
local player = game.Players.LocalPlayer
local EternalSouI = game.Workspace:WaitForChild("EternalSouI")
local Mouse = player:GetMouse()

Mouse.KeyDown:connect(function(Key)
if Key == "x" then
if (EternalSouI.Character ~= nil) then
EternalSouI.Character.Humanoid.WalkSpeed = 25
end
end
end)


It still didn't change my walkspeed. I even changed it to 50 if the 25 speed didn't have a difference but it still did not change my walkspeed. I did not use F5 test mode either.
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
24 May 2015 09:25 PM
bump
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
25 May 2015 01:34 PM
LocalScript in StarterPack

local plr = game.Players.LocalPlayer
local m = plr:GetMouse()

m.KeyDown:connect(funciton(key)
if key == "x" then
workspace[plr.Name].Humanoid.WalkSpeed = 50
end
end)
Report Abuse
EternalSouI is not online. EternalSouI
Joined: 11 Mar 2012
Total Posts: 270
25 May 2015 02:37 PM
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()

m.KeyDown:connect(funciton(key)
if key == "x" then
workspace[EternalSouI].Humanoid.WalkSpeed = 50
end
end)



Is it like this? Because it did not change my speed when I press x. I typed the script inside a local script and put the local script into the starterpack.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
25 May 2015 03:04 PM
http://wiki.roblox.com/index.php?title=UserInputService
http://wiki.roblox.com/index.php?title=RemoteEvent

UserInputService is better than keydown and remoteevents for filtering.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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