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
 

Re: I made a gun that does absolutely 0 damage..

Previous Thread :: Next Thread 
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:09 PM
local tool=script.Parent
local reloading=false

function fire(d)

bullet=Instance.new("Part")
bullet.FormFactor="Custom"
bullet.Size=Vector3.new(0.4,0.2,0.2)
bullet.BrickColor=BrickColor.new("Really black")
bullet.Position=tool.Handle.Position+(d*5)
bullet.Velocity=d*140

bullet.Touched:connect(function(hit)
bullet:remove()
chr=hit.Parent
if game.Players:GetPlayerFromCharacter(chr) and chr:findFirstChild("Humanoid") then
plr=game.Players:GetPlayerFromCharacter(chr)
if chr.Humanoid.Health>0 then
chr.Humanoid:TakeDamage(math.random(50,75))
end
end
end)

force=Instance.new("BodyForce")
force.force=Vector3.new(0,3,0)
force.Parent=bullet

bullet.Parent=game.Workspace

end

tool.Activated:connect(function()

if tool.Enabled and not reloading then

chr=tool.Parent

if game.Players:GetPlayerFromCharacter(chr)==script.Parent.plr.Value then

if chr:findFirstChild("Humanoid") then

if chr.Humanoid.Health>0 then
reloading=true

hum=chr.Humanoid

targetPos=hum.TargetPoint
lookAt=(targetPos-chr.Head.Position).unit
fire(lookAt)

wait(0.35)

reloading=false
end

end
end

end

end)

I have the damage scripted in there, but it still does 0 damage.

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
09 Feb 2014 12:11 PM
Remove the bullet after the damage is distributed. Perhaps that may work.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
09 Feb 2014 12:13 PM
lel, hes right
Report Abuse
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:13 PM
@MARIO, i've tried that.

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
09 Feb 2014 12:13 PM
It's also a good idea to replicate a touch script seperately from the tool, and place a clone of it into the bullet on fire.
Report Abuse
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:14 PM
And how would I do that?

I'm sorta new to scripting.

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:15 PM
And sometimes it disappears before it hits it's target..

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
09 Feb 2014 12:16 PM
If u made this, and can't figure this out, ur runnning into trouble.... but....


local tool=script.Parent
local reloading=false

function fire(d)

bullet=Instance.new("Part")
bullet.FormFactor="Custom"
bullet.Size=Vector3.new(0.4,0.2,0.2)
bullet.BrickColor=BrickColor.new("Really black")
bullet.Position=tool.Handle.Position+(d*5)
bullet.Velocity=d*140

bullet.Touched:connect(function(hit)
chr=hit.Parent
if game.Players:GetPlayerFromCharacter(chr) and chr:findFirstChild("Humanoid") then
plr=game.Players:GetPlayerFromCharacter(chr)
if chr.Humanoid.Health>0 then
chr.Humanoid:TakeDamage(math.random(50,75))
bullet:remove() -- move it here
end
end
end)

force=Instance.new("BodyForce")
force.force=Vector3.new(0,3,0)
force.Parent=bullet

bullet.Parent=game.Workspace

end

tool.Activated:connect(function()

if tool.Enabled and not reloading then

chr=tool.Parent

if game.Players:GetPlayerFromCharacter(chr)==script.Parent.plr.Value then

if chr:findFirstChild("Humanoid") then

if chr.Humanoid.Health>0 then
reloading=true

hum=chr.Humanoid

targetPos=hum.TargetPoint
lookAt=(targetPos-chr.Head.Position).unit
fire(lookAt)

wait(0.35)

reloading=false
end

end
end

end

end)
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
09 Feb 2014 12:17 PM
Make a seperate script called "DamageScript", place it in the tool. Inside add this code:

script.Parent.Touched:connect(function(hit)
chr=hit.Parent
if game.Players:GetPlayerFromCharacter(chr) and chr:findFirstChild("Humanoid") then
plr=game.Players:GetPlayerFromCharacter(chr)
if chr.Humanoid.Health>0 then
chr.Humanoid:TakeDamage(math.random(50,75))
bullet:remove()
end
end
end)


---------------------------------------------------

local tool=script.Parent
local reloading=false

function fire(d)

bullet=Instance.new("Part")
bullet.FormFactor="Custom"
bullet.Size=Vector3.new(0.4,0.2,0.2)
bullet.BrickColor=BrickColor.new("Really black")
bullet.Position=tool.Handle.Position+(d*5)
bullet.Velocity=d*140

damageclone = script.Parent.DamageScript:Clone()

damageclone.Parent = bullet


force=Instance.new("BodyForce")
force.force=Vector3.new(0,3,0)
force.Parent=bullet

bullet.Parent=game.Workspace

end

tool.Activated:connect(function()

if tool.Enabled and not reloading then

chr=tool.Parent

if game.Players:GetPlayerFromCharacter(chr)==script.Parent.plr.Value then

if chr:findFirstChild("Humanoid") then

if chr.Humanoid.Health>0 then
reloading=true

hum=chr.Humanoid

targetPos=hum.TargetPoint
lookAt=(targetPos-chr.Head.Position).unit
fire(lookAt)

wait(0.35)

reloading=false
end

end
end

end

end)
Report Abuse
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:18 PM
@kev, I did.

And it only shoots in studio F6, why is that?

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
09 Feb 2014 12:19 PM
"And sometimes it disappears before it hits it's target.."

Because you removed the bullet before it checks the condition for if a humanoid is present or not.
Report Abuse
gyoper357 is not online. gyoper357
Joined: 28 Jul 2009
Total Posts: 32207
09 Feb 2014 12:21 PM
Ah, anyways, on your post, before the
------------------------------------
is that the part I put into a seperate script? Or all of it?

SYSTEM = Something You Shouldn't Trust Ever MAAAAAAAAAAAAAN
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
09 Feb 2014 12:22 PM
Seperate of course.
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