brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 18 May 2013 07:09 PM |
I'm trying to learn how to make a gun give KOs, any pointers or tips?
|
|
|
| Report Abuse |
|
|
|
| 18 May 2013 07:16 PM |
Yus, make the tool give the bullet a ObjectValue and a script, make the ObjectValue's Value be the Player who activated the tool, and the script should have the Touched event (a part that says function onHit(whatever) ) in one of its lines, that kills the player who got hit by the bullet and at the same time give the killer +1 KO by checking the Object Value.
^Tell me how hard is that to understand |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 07:17 PM |
Woops made an error:
...the script should have the Touched event (a part that says function onHit(whatever) ) in one of its lines, make the function kill the player who got hit by the bullet and at the same time give the killer +1 KO by checking the Object Value. |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 18 May 2013 07:19 PM |
| How does it know when the target dies? |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 07:24 PM |
you can make it instantly kill the player or check if it died by using this lines after the lines which made the player take damage:
if hit.Humanoid.Health < 1 then --just incase the health changes to a negative number --DoStuffHere end |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 18 May 2013 07:26 PM |
I'm looking at the LinkedSlingshot and i'm guessing this is the code?
function onTouched(hit) humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid~=nil then tagHumanoid(humanoid) humanoid:TakeDamage(damage) else damage = damage / 2 if damage < 1 then connection:disconnect() pellet.Parent = nil end end end
function tagHumanoid(humanoid) -- todo: make tag expire local tag = pellet:findFirstChild("creator") if tag ~= nil then -- kill all other tags while(humanoid:findFirstChild("creator") ~= nil) do humanoid:findFirstChild("creator").Parent = nil end
local new_tag = tag:clone() new_tag.Parent = humanoid debris:AddItem(new_tag, 1) end end
|
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 18 May 2013 07:29 PM |
@Brayden, Humanoid.Died:connect(function() end) |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 07:31 PM |
| Well... thats the code for the pellets the slingshot shoots, you can use it if you want... btw. I never understand why roblox uses sooooo many functions |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 18 May 2013 07:47 PM |
| @btft, I should check humanoid:Died:connect(function() instead of humanoid.Health < 0? |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 18 May 2013 07:51 PM |
| No. Because you are checking each time the bullet hits. I was just making a point. |
|
|
| Report Abuse |
|
|