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
 

Why wont this piece of code work? (gun script)

Previous Thread :: Next Thread 
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
13 Dec 2013 01:02 PM
CurAmmo = script.Parent.CurAmmo.Value
MagAmount = script.Parent.MagAmount.Value
Hit1 = math.random(50,115)
Hit2 = math.random(50,90)
Hit3 = math.random(50,65)
RawDmg = (Hit1 + Hit2 + Hit3)/3
HitDmg = math.celi(Dmg)
TotalAmmo = CurAmmo * MagAmount

bulletFired = false
EnoughAMMO = true

function Fire()
if EnoughAMMO == true then
bullet = Instance.new("Part",game:GetService("Lighting"))
bullet.Shape = "Ball"
bullet.Name = "Bullet"
bullet.Size = Vector3.new(.5,.5,.5)
bullet.Position = script.Parent.Muzzle.Position
bullet.BodyForce.force = Vector3.new(100,0,0)
bullet.Touched:connect(function(hit)
bulletFired = true
if hit.Parent:findFirstChild("ForceField") ~= nil then
bulletFired = false
return
elseif hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.findFirstChild("Humanoid").TakeDamage(Dmg)
bulletFired = false
else
bullet:Destroy()
end
end






script.Parent.Button1Down:connect(Fire)

script.Parent.Button2Down:connect(Scope)

script.Parent.KeyDown:connect(key)

"Don't Panic"- HHGTTG
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
13 Dec 2013 01:48 PM
bump

"Don't Panic"- HHGTTG
Report Abuse
Shonysky is not online. Shonysky
Joined: 05 Aug 2013
Total Posts: 361
13 Dec 2013 01:55 PM
hit.Parent.findFirstChild("Humanoid"):TakeDamage(Dmg)
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
13 Dec 2013 03:30 PM
bump

"Don't Panic"- HHGTTG
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
13 Dec 2013 03:49 PM
It still isn't workn for some reason

"Don't Panic"- HHGTTG
Report Abuse
GiganticGulian is not online. GiganticGulian
Joined: 18 Feb 2011
Total Posts: 2233
13 Dec 2013 03:52 PM
ogm just watch the output e.e
Report Abuse
skyarex is not online. skyarex
Joined: 21 Mar 2010
Total Posts: 12989
13 Dec 2013 04:03 PM
@gi

I saw the output. I am posting here because i don't know why it isn't working ._.

"Don't Panic"- HHGTTG
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
13 Dec 2013 04:07 PM
You cannot parent Parts and Models to lighting anymore?
Report Abuse
VilleSlay is not online. VilleSlay
Joined: 14 May 2011
Total Posts: 1405
13 Dec 2013 04:30 PM
bullet = Instance.new("Part",game:GetService("Lighting"))

This won't be visible for the player. You are aware of that, right?
Report Abuse
VilleSlay is not online. VilleSlay
Joined: 14 May 2011
Total Posts: 1405
13 Dec 2013 04:34 PM
HitDmg = math.celi(Dmg)

math.ceil is the correct way to do it.

Also, you need to make Dmg a number. As of right now, it is just an argument.
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
13 Dec 2013 05:35 PM
:findFirstChild

--------NOT--------
--------NOT--------
--------NOT--------

.findFirstChild
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