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: Advanced Scripting

Previous Thread :: Next Thread 
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 03:29 PM
Today ima show you people how to do a simple and advanced Key Press Event
This is very helpful because it helps you to do many things in your game like equipping tools,opening and closing things,spawning items and more..
Ima do a simple Key Press Event with an Example.

1.Add a tool to Workspace
2.Add a script
3.In that script type


game.Players.LocalPlayer

tool = script.Parent

tool.Equipped:connect(function(mouse)


mouse.KeyDown:connect(function(key)
if key == "q" then
print(You Pressed q)
local speedboost = 1.25
end
end

If we test it in ROBLOX studio,if the player has the tool in thier hand and presses q,the player will get a speedboost,their current speed will be 17.25.The Normal Speed in Roblox is 16.
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:30 PM
DO NOT USE THE ABOVE EXAMPLES ^

KeyDown/KeyUp are deprecated. Use the UserInputService instead:
http://wiki.roblox.com/?title=API:Class/UserInputService


Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
26 Jun 2016 03:30 PM
Actually you forgot to put quotes around that printed string
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:31 PM
you don't need quotes or parenthesis, you can use apostrophes


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:31 PM
Oh jeez sorry I thought I was responding to another thread where I use apostrophes in one of my prints :\


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 03:35 PM
UHHHHHHHHHHHH..........So Im Correct then.Yeah but I did forget to put the quotes for print.Instead of print(You Pressed q)

Put print("You Pressed q")

Sorry Guys.Mistakes are made though...
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:36 PM
It's just that KeyDown is deprecated, and you shouldn't use it at all. It may be functional now, but, it might not be in the near future.


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 03:41 PM
I used it in ROBLOX Studio and Its working
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:42 PM
yeah, for now
but like I said twice already, you shouldn't use it at all. It is subject to removal, as it is deprecated[3]


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 03:44 PM
Well if it's deprecated I will try to find another way how to do it
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Jun 2016 03:44 PM
Use the link to UserInputService that I linked you to above.=


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 03:45 PM
oh ok thx
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 04:04 PM
Now I'm going to be showing you people how to make Multiple Background Music

1.You insert a Sound into Workspace

2.Enter A SoundId For Example....I'll be using the SoundId "274015254" Which Is The Song Jetta - I'd Love To Change the world

3.Name The Sound "Sound1"

If You made multiple sounds then name the 2nd Sound "Sound2" and the 3rd sound "Sound3" and you can continue

4.Insert a Local Script

5.In That Local Script type

while true do
wait() <- This prevents your game from crashing
game.Workspace.Sound1:Play()
wait(120) <- I gave the song 2 minutes to play
game.Workspace.Sound1:Stop()
wait(2)
game.Workspace.Sound2:Play()
wait(120)
game.Workspace.Sound2:Stop()
end

With this script,This will allow you to play Multiple Background Music and will loop forever.

If you don't want it to loop forever in the server then remove while true do,the end and the wait that prevents the game from crashing.
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
26 Jun 2016 04:06 PM
One more thing to add.

You must put the LocalScript into StarterGUI

That's All
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