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: Why does this reload script crash studio?

Previous Thread :: Next Thread 
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 09:14 AM
mouse.KeyDown:connect(function(key)
if key == reload then
print("key has been pressed")
if ammo < 10 and ammostore > 10 then
reloading = true
local difference = ammo - 10
ammo = ammo + difference
print(ammo .. " " .. difference)
ammostore = ammostore - difference
print(ammostore)
wait(reloadtime)
reloading = false

ammostore and ammo are defined.
Thanks in advance

Women are like fine wine, I can't get their tops off
Report Abuse
AdvancedDrone is not online. AdvancedDrone
Joined: 17 Apr 2010
Total Posts: 2599
16 Aug 2015 09:36 AM
what is "if key == reload"? there isnt a reload variable and dont use keyDown its deprecated use UserInput

most of your variables dont exist

suport http://www.roblox.com/Forum/ShowPost.aspx?PostID=170559579
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 01:44 PM
I'm making a gun script for a friend, so it's configurable

damage = 30 -- Set this to how much damage you want the gun to do



RPM = 600 -- How many rounds a minute can the gun fire?
ammo = 10 -- How much ammo in a clip do you want?
ammostore = 100 -- How many stored rounds do you want?
reload = "r" -- Change this to what button you want to use to reload
reloadtime = 2 -- Set this to how long you want to take to reload


Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 01:45 PM
keyDown is depreciated, please use UserInputService instead

http://wiki.roblox.com/index.php?title=Userinputservice


jeb get me the seperatrons
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 01:47 PM
Alright, thanks. But doesn't explain why it crashes

Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 01:48 PM
'Alright, thanks. But doesn't explain why it crashes'

probably your use of keyDown


jeb get me the seperatrons
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 01:48 PM
Er, quick crash course in UserInputService? The wiki doesn't give an example of it.

Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 01:50 PM
'Er, quick crash course in UserInputService? The wiki doesn't give an example of it.'

if you wrote all that code, you're able to figure out how to use UIS using the functions and events of it in the wiki.


jeb get me the seperatrons
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
16 Aug 2015 01:50 PM
Not sure, but shouldn't it be

local difference = 10 - ammo
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 01:55 PM
@Astrain, I did write the code, I'm a fairly regular forumer here, but I didn't learn off the wiki and I'm fairly bad at self-education. Only found out how to use arguments and parameters recently...

Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 01:55 PM
'@Astrain, I did write the code, I'm a fairly regular forumer here, but I didn't learn off the wiki and I'm fairly bad at self-education. Only found out how to use arguments and parameters recently...'

well then, can't help you

10/10 siggy though


jeb get me the seperatrons
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 01:58 PM
I BELIEVE I need to use InputBegan (), and the wiki says:
InputBegan ( InputObject input, bool gameProcessedEvent )
Fired when a user begins interacting via a Human-Computer Interface device.

But I wouldn't put InputBegan(reload), would I?


Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 01:59 PM
'But I wouldn't put InputBegan(reload), would I?'

no

InputBegan gives you a keyCode

then you go:

UIS.InputBegan:connect(function(kc)
if kc = Enum.KeyCode.R then
-- code
end
end)


jeb get me the seperatrons
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 02:04 PM
Why not?

Women are like fine wine, I can't get their tops off
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 02:06 PM
Oh, alright. That doesn't seems fairly simple, alright thanks. I'll fiddle around with it, and see how I do. Could I use variables here, and would I need to use "r" or just r?

Women are like fine wine, I can't get their tops off
Report Abuse
Astrain1 is not online. Astrain1
Joined: 27 Mar 2013
Total Posts: 18697
16 Aug 2015 02:08 PM
'Oh, alright. That doesn't seems fairly simple, alright thanks. I'll fiddle around with it, and see how I do. Could I use variables here, and would I need to use "r" or just r?'

it'll bring up an autocomplete box soo


jeb get me the seperatrons
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 03:36 PM
Still crashes...


Women are like fine wine, I can't get their tops off
Report Abuse
Darkggod0 is not online. Darkggod0
Joined: 08 Jan 2013
Total Posts: 2946
16 Aug 2015 04:07 PM
@Astrain1

Iv'e made large coded scripts for localscripts for tools in my Anime games, all using the Keydown Function if its deprecated does it mean it will not work in a future update and I'm going to have to convert all the functions????


~Darkggod Uchiha~
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 04:20 PM
No, still works, just it's been replaced

Women are like fine wine, I can't get their tops off
Report Abuse
BluesteelBoyz is not online. BluesteelBoyz
Joined: 15 Feb 2012
Total Posts: 1841
16 Aug 2015 04:21 PM
'what is ifkey'
lolwhat

http://web.roblox.com/games/281290108/Blocky-Dudes-Friends-Lodge
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
16 Aug 2015 04:24 PM
Learn how to tab your code.


local CAS = game:GetService("ContextActionService")

function reloadGun(name, state, input)
if state == Enum.UserInputState.Begin then
--Your code here
end
end

CAS:BindAction("ReloadGun", reloadGun, true, Enum.KeyCode.R, Enum.KeyCode.ButtonX)
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
16 Aug 2015 04:30 PM
more like wolfgangvonidiot
Report Abuse
BluesteelBoyz is not online. BluesteelBoyz
Joined: 15 Feb 2012
Total Posts: 1841
16 Aug 2015 04:33 PM
Don't make fun of people...

http://web.roblox.com/games/281290108/Blocky-Dudes-Friends-Lodge
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
16 Aug 2015 04:33 PM
You're back!?

Women are like fine wine, I can't get their tops off
Report Abuse
BluesteelBoyz is not online. BluesteelBoyz
Joined: 15 Feb 2012
Total Posts: 1841
16 Aug 2015 04:34 PM
who??

http://web.roblox.com/games/281290108/Blocky-Dudes-Friends-Lodge
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