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 » Scripters
Home Search
 

Re: Is there a more better way to write this script.

Previous Thread :: Next Thread 
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 10:11 AM
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()

Rightshoulder = game.Workspace.Player.Torso["Right Shoulder"]
Leftshoulder = game.Workspace.Player.Torso["Left Shoulder"]

-- function
function combat(key)
key = key:lower()
if key == "q" then

for dat = 1, 10 do
Leftshoulder.C0 = Leftshoulder.C0 *CFrame.Angles(0,0,math.rad(-10))
wait()
end

for dat = 1, 10 do
Leftshoulder.C0 = Leftshoulder.C0 *CFrame.Angles(0,0,math.rad(10))
wait()
end

-- else if the key e gets pressed the right arm moves


else if key == "e" then

for dat = 1, 10 do
Rightshoulder.C0 = Rightshoulder.C0 *CFrame.Angles(0,0,math.rad(10))
wait()

end


for dat = 1, 10 do
Rightshoulder.C0 = Rightshoulder.C0 *CFrame.Angles(0,0,math.rad(-10))
wait()
end


end
end
end

mouse.KeyDown:connect(combat)


Also where should I put the debounce?
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 10:41 AM
I am so glad you asked. Events of UserInputService replaced KeyDown and KeyUp. You should not use KeyDown or KeyUp anymore because they've been depreciated.
Report Abuse
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
22 May 2015 10:46 AM
In my main's models i have a UserInputService example. Main's name: TheNewChicken

Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 11:38 AM
The example is pretty confusing, can you give me an example that uses print?
Report Abuse
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
22 May 2015 11:55 AM
Sorry but i don't have time. I will later, but im very busy.
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 01:46 PM
Anyone else able togive me an Inputservice example using print
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
22 May 2015 01:49 PM
In my models I have the BindsManager I'm using to drive input for Valkyrie. Import it and require() it in a script, and then use :BindInputDown(key, function(inputData) {code} end)
inputData has a single key (inputData.Down) which is true if the key is down
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 02:08 PM
I read through the BindsManager, it's too hard for me to read it lol.

Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:09 PM
Check wiki.roblox.com then. :P

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
22 May 2015 02:12 PM
http://wiki.roblox.com/index.php?title=ContextActionService_tutorial
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:13 PM
My keyboard is broken, so it would be difficult for me to explain UserInputService to you and give examples. I'm using speech recognition right now to type this.
Report Abuse
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
22 May 2015 02:14 PM
@amanda

Start menu

all programs

accesories

ease of access

onscreen keyboard

Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:15 PM
That is so annoying [the keyboard].

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 02:17 PM
This is getting way too confusing for me. All I want to know is how to use the function UserInputService, what is the purpose of KeyUp and KeyDown being depreciated if UserInputService is harder too understand. All I want is an example of the UserInputService where I press a button and then it would print something. If that is hard/long to make then I don't see the purpose of it.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:19 PM
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.W then
print("You are pressing W")
end
end
end)
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:22 PM
UserInputService is fairly new, so not everyone has supreme knowledge of it yet. I can assure you it is not extremely hard to understand, if you have any questions I'll be sure to answer them.
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 02:25 PM
Thanks


Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:25 PM
UserInputService can do a lot. It works with key bindings, but you can also use it to bind input from a touch screen device, or even a console controller. It creates a more unified way to detect input.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:26 PM
I wonder if ROBLOX makes its own console for UserinputService...

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 02:28 PM
local UIS = game:GetService("UserInputService")

function wat(input)

if input.KeyCode == Enum.KeyCode.W then
print("You are pressing W")
end
end
UIS.InputBegan:connect(wat)



does the gameproccesedevent do?
Report Abuse
Raidorz is not online. Raidorz
Joined: 28 Apr 2011
Total Posts: 5221
22 May 2015 02:28 PM
Oh and that is how I script stuff, functions on top, connecting below.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:34 PM
GameProcessedEvents occur when interacting with a GUI and moving the camera with keyboard controls. I'm not sure if much else triggers it, however this is enough to make a check for it. The main reason people check for it is to make sure the events do not trigger when typing in a chat GUI.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
22 May 2015 02:41 PM
Roblox Console's name would be the Ro-Sole.. :P

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
22 May 2015 02:43 PM
Fixed my keyboard.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.LeftShift then
print("SHIFTING")
end
end
end)

--

An example of the power of Enums. Don't have to find any weird key's byte, because they are named.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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