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 |
|
|
|
| 09 Feb 2014 12:11 PM |
| Remove the bullet after the damage is distributed. Perhaps that may work. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|