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: Value Changing Magazines

Previous Thread :: Next Thread 
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
16 Apr 2016 08:33 PM
So, in my game, you need to be able to find magazines to increase the ammo that you are carrying. I have a stored ammo value in the gun, which controls the amount of ammo that you have before you run out. So the magazine needs to be able to change that value. I think the easiest way would be to make the magazine a tool that, when used, changes the value and destroys itself. Does anyone have any way to do this?
Report Abuse
brack4712 is not online. brack4712
Joined: 07 Mar 2009
Total Posts: 243
16 Apr 2016 09:13 PM
If you want to have the magazines randomly spawning around the map and then you click them and they change the value it would be someone like this

Ofc, assuming you have the magazine on the ground, insert a Click Detector and a LocalScript.

Code:
function onClicked()
game.Players.LocalPlayer.Backpack.Gun.ammo = 25
wait(1)
script.Parent:Remove()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)


This should work.
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
18 Apr 2016 04:29 PM
Wait... but where do I put the name of my gun so that it specifies?
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
18 Apr 2016 06:13 PM
Bump
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
20 Apr 2016 04:21 PM
bump...
Report Abuse
Developmant is not online. Developmant
Joined: 28 Feb 2013
Total Posts: 329
20 Apr 2016 04:36 PM
I don't really recommend using ClickDetectors.

Just use the Button1Down event in UserInputService.


-- 4 8 15 16 23 42
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
21 Apr 2016 08:14 AM
Any other ideas? Currently,I'm thinking about making the mag a tool using FunctionOnUse.
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
21 Apr 2016 08:27 AM
this is simple

user input service, detect mouse button 1 down, if the target is the magazine(an object), then change the ammo value in the gun


#Code print("Add 13,000 posts")
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
21 Apr 2016 09:03 AM
I just need something to work for now until I can find something better. Thanks for the idea though. Anyone else?
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
21 Apr 2016 11:50 AM
Bump
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
21 Apr 2016 11:53 AM
You could do a touch instead of click..
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
21 Apr 2016 04:46 PM
Any other scripts or ideas?
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
22 Apr 2016 05:26 PM
Bumpety bump bump
Report Abuse
brack4712 is not online. brack4712
Joined: 07 Mar 2009
Total Posts: 243
22 Apr 2016 05:30 PM
In reply to your question about my reply, you don't need to put the name anywhere. It just changes the ammo. You may need to change the location of the ammo, but other than that, it should work fine. Click detectors are personal preference. If you don't want to use it, fine by me :)
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
23 Apr 2016 10:54 AM
Thanks. I'll try it now to see if it works.
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
23 Apr 2016 06:00 PM
What do I replace with "Gun"?




Couldn't try it yet, because my guns broke. Trying to fix that.
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
23 Apr 2016 07:10 PM
The guns name...
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
24 Apr 2016 06:41 AM
Tried that. And, yes, I did try to change "ammo" with my ammo value's name.
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
24 Apr 2016 11:17 AM
Is it in a server or local script?
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
24 Apr 2016 11:37 AM
Local. In the gun. The gun's name is QBB-95 LSW. It thinks that the "95" is a number value.
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
24 Apr 2016 12:12 PM
function onClicked()
game.Players.LocalPlayer.Backpack:FindFirstChild"QBB-95 LSW".ammo = 25
wait(1)
script.Parent:Remove()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
24 Apr 2016 01:37 PM
Doesn't work.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
24 Apr 2016 01:45 PM
Okay listen its not that hard. Either 1. make a gui pop up when you are close to the magazine and if you click a button change the value or 2. change the value when you step over the magazine, or 3. change the value with a brick that is a bit bigger than the magazine but transparency 1 and clicking on it.

magazineBrick.ClickDetector.MouseClick:connect(function(player)
local gun = player.Character:FindFirstChild("Gun")
if gun then
local ammo = gun:WaitForChild("Ammo")
ammo.Value = ammo.Value + magazineBrick.MagazineAmmo.Value
end
end)


Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
24 Apr 2016 04:42 PM
Um... Also doesn't work. I'm probably doing something wrong.
Report Abuse
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
24 Apr 2016 06:56 PM
Bump.....
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