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: .KeyPressed

Previous Thread :: Next Thread 
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 08:33 PM
I need a script that when i press Shift, my walkspeed is 32, when i relase, its 16


And i need to change the left arms CFrame sticking out to the left side, almost straight , but not quite.

I have this

function KeyPress()

end
:connect(KeyPress)



thats all i know :(




even if all i can get is the walkspeed, ill taker it but pls the arm sticking out ALMOST straight
Report Abuse
Kyrothehero is not online. Kyrothehero
Joined: 14 Aug 2012
Total Posts: 306
10 Apr 2014 08:56 PM
it's .Key-Down without the -
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 09:33 PM
Also the arm goes back when shift is relased.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:34 PM
Local script:

local mouse = Game.Players.LocalPlayer:GetMouse()

local function keyPress(key)
if key == "x" then
Game.Players.LocalPlayer.Character:BreakJoints() --Kill player if they click x
end
end

mouse.KeyPressed:connect(keyPress)
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 09:48 PM
NOT WORKING:







local mouse = Game.Players.LocalPlayer:GetMouse()

local function keyPress(key)
if key == "e" then
Game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 32
elseif key == "q" then
game.Players.LocalPlayer.Humanoid.WalkSpeed = 16
elseif key == "x" then
game.Players.LocalPlayer.Character:BreakJoints()
elseif key == "f" then
game.Players.LocalPlayer.Character.Animate.Disabled = true
elseif key == "r" then
game.Players.LocalPlayer.Character.Animate.Disabled = false
elseif key == "z" then
game.Players.LocalPlayer.Character.Humanoid.Health = math.huge
game.Players.LocalPlayer.Character.Humanoid.MaxHealth = math.huge
elseif key == "c" then
game.Players.LocalPlayer.Character.Humanoid.Health = 100
game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 100
end
end
mouse.KeyPressed:connect(keyPress)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 09:49 PM
Im actually going to help you.

repeat wait() until game.Players.LocalPlayer.Character
plyr = game.Players.LocalPlayer
char = plyr.Character
mouse = plyr:GetMouse()

mouse.KeyDown:connect(function(key)
Key = key:byte() --Not lower, byte, completely different.
if Key == 48 then --key:byte(48) = Left Shift
hum = char:FindFirstChild("Humanoid")
if hum then
hum.WalkSpeed = 32
end
end
end)

--local script inside backpack
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:54 PM
local player = Game.Players.LocalPlayer --For convenience
local character = player.Character or player.CharacterAdded:wait() --For convenience and efficiency
local mouse = player:GetMouse()

local function keyPress(key)
      if key == "e" then
            character.Humanoid.WalkSpeed = 32
      elseif key == "q" then
            character.Humanoid.WalkSpeed = 16
      elseif key == "x" then
            character:BreakJoints()
      elseif key == "f" then
            character.Animate.Disabled = true
      elseif key == "r" then
            character.Animate.Disabled = false
      elseif key == "z" then
            character.Humanoid.Health = math.huge
            character.Humanoid.MaxHealth = math.huge
      elseif key == "c" then
            character.Humanoid.Health = 100
            character.Humanoid.MaxHealth = 100
      end
end
mouse.KeyPressed:connect(keyPress)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:55 PM
Use keydown, keypressed is locked apparantly
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 09:55 PM
Mhmm

"More efficient"

"Works"

"Is better"
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:56 PM
I said it's more efficient then doing 2 events.
Works, well apparently not anymore.
Is better compared to 2 events (when it worked).
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 09:57 PM
Well

Obviously, youre living in the past, things changed.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:58 PM
"living in the past"

Too bad the past no longer exists, so how is that possible. Exactly.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 09:58 PM
Shoot me now
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 09:59 PM
Don't think of suicide, it's never the answer.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 10:00 PM
Please
Shoot
Me
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 10:02 PM
local player = Game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local mouse = player:GetMouse()

local function keyPress(key)
if key == "e" then
character.Humanoid.WalkSpeed = 32
elseif key == "q" then
character.Humanoid.WalkSpeed = 16
elseif key == "x" then
character:BreakJoints()
elseif key == "f" then
character.Animate.Disabled = true
elseif key == "r" then
character.Animate.Disabled = false
elseif key == "z" then
character.Humanoid.Health = math.huge
character.Humanoid.MaxHealth = math.huge
elseif key == "c" then
character.Humanoid.Health = 100
character.Humanoid.MaxHealth = 100
end
end
mouse.KeyDown:connect(keyPress)




*mercy shoots*
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
10 Apr 2014 10:03 PM
ty for shooting me
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 10:07 PM
I just tested it and it worked:

local player = Game.Players.LocalPlayer
local character = player.Character

local mouse = player:GetMouse()

local function keyPress(key)
if key == "e" then
character.Humanoid.WalkSpeed = 32
elseif key == "q" then
character.Humanoid.WalkSpeed = 16
elseif key == "x" then
character:BreakJoints()
elseif key == "f" then
character.Animate.Disabled = true
elseif key == "r" then
character.Animate.Disabled = false
elseif key == "z" then
character.Humanoid.Health = math.huge
character.Humanoid.MaxHealth = math.huge
elseif key == "c" then
character.Humanoid.Health = 100
character.Humanoid.MaxHealth = 100
end
end
mouse.KeyDown:connect(keyPress)
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 10:09 PM
thnx it works
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 10:22 PM
Ok i added 3more, Staff RemoveStaff and :LoadCharacter me, it doesnt work,but the others still do, so fix em pls



t = Instance.new("Tool",game.ReplicatedStorage)
t.Name = 'Wizard Staff'
t.GripPos = Vector3.new(0,-2,0)
p = Instance.new("Part",t)
p.FormFactor = 'Custom'
p.Name = 'Handle'
p.CanCollide = false
m = Instance.new("SpecialMesh",p)
m.MeshId = 'http://www.roblox.com/asset/?id=18434043'
m.TextureId = 'http://www.roblox.com/asset/?id=26017177'
Fire = Instance.new ("Fire",t.Handle)


local player = Game.Players.LocalPlayer
local character = player.Character

local mouse = player:GetMouse()

local function keyPress(key)
if key == "e" then
character.Humanoid.WalkSpeed = 32
elseif key == "q" then
character.Humanoid.WalkSpeed = 16
elseif key == "x" then
character:BreakJoints()
elseif key == "f" then
character.Animate.Disabled = true
elseif key == "r" then
character.Animate.Disabled = false
elseif key == "z" then
character.Humanoid.Health = math.huge
character.Humanoid.MaxHealth = math.huge
elseif key == "c" then
character.Humanoid.Health = 100
character.Humanoid.MaxHealth = 100
elseif key == "v" then
player:LoadCharacter()
elseif key == "k" then
bmh = game.ReplicatedStorage['Wizard Staff']:clone()
bmh.Parent = player.Backpack
elseif key == "l" then
player.Backpack['Wizard Staff']:Destroy()
end
end
mouse.KeyDown:connect(keyPress)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 10:23 PM
You can't loadcharacter from a local script and you should make sure Wizard Staff is not nil and there is a Wizard Staff in Replicated Storage
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 10:24 PM
dang, wait, i fixed the staff thingy, is there anotehr way LIKE loadCharacter() cuz if somthing like getting punished happens..
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 10:26 PM
Change the player's character to something temporarily (Model with a part named torso in it and a Humamoid in it)
Report Abuse
McChicken72 is not online. McChicken72
Joined: 09 Feb 2013
Total Posts: 1115
10 Apr 2014 10:27 PM
Could i just remove the character, using :Destroy() ( and if so, would i do it in Workspace or Players)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Apr 2014 10:32 PM
No, you won't respawn if you just remove the character and if you remove the player (not character) than you would have to rejoin to actually play again
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