|
| 03 Dec 2011 07:37 AM |
| I'm making a script where irt awards cash if you kill someone. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 03 Dec 2011 07:52 AM |
| You guys are supposed to help. What is the line? |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 03 Dec 2011 07:57 AM |
local tag = humanoidLfindFirstChild("creator")
Creator is an invisible value that pops up inside a humanoid when it dies, it says who killed it. |
|
|
| Report Abuse |
|
|
|
| 03 Dec 2011 08:04 AM |
| You would use it with respawn right? |
|
|
| Report Abuse |
|
|
Wil2
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 728 |
|
|
| 03 Dec 2011 08:07 AM |
| here's a hint: Read the linked leaderboard, and change it(copy and paste the code in another script inorder to edit it) so it can award cash instead of wos and kos. |
|
|
| Report Abuse |
|
|
|
| 03 Dec 2011 08:10 AM |
| Wil, I like to do things on my own. I don't like to copy and paste stuff that I didn't make. |
|
|
| Report Abuse |
|
|
Wil2
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 728 |
|
|
| 03 Dec 2011 08:11 AM |
| copy and paste to help you code it, so you know you won't have errors in your copy and delete the copied code as you go. |
|
|
| Report Abuse |
|
|
|
| 03 Dec 2011 08:13 AM |
Yeah, well otherwise, we cant help you. Just use the linked leaderboard;) (Yes. Im not BC, but I used to play and i had a pretty good game. Just checking on Roblox, seeing whats going on ;P)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Dec 2011 08:41 AM |
Well, Wil. This is what I have.
game.Players.PlayerAdded:connect(function(p) wait(.1) ldr = Instance.new("IntValue") ldr.Name = "leaderstats" ldr.Parent = p stuff = Instance.new("IntValue") stuff.Name = "Cash" stuff.Value = 50 stuff.Parent = ldr end) function onHumanoidDied(humanoid, player)
-- do short dance to try and find the killer
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
handleKillCount(humanoid, player) end
function onPlayerRespawn(property, player) -- need to connect to new humanoid if property == "Character" and player.Character ~= nil then local humanoid = player.Character.Humanoid local p = player local h = humanoid humanoid.Died:connect(function() onHumanoidDied(h, p) end ) end end
function getKillerOfHumanoidIfStillInGame(humanoid) -- returns the player object that killed this humanoid -- returns nil if the killer is no longer in the game
-- check for kill tag on humanoid - may be more than one - todo: deal with this local tag = humanoid:findFirstChild("creator")
-- find player with name on tag if tag ~= nil then local killer = tag.Value if killer.Parent ~= nil then -- killer still in game return killer end end
return nil end
function handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("leaderstats") if stats ~= nil then local kills = stats:findFirstChild("Cash") if killer ~= player then kills.Value = kills.Value + 10 else kills.Value = kills.Value - 10 end end end end
(It doesn't work) |
|
|
| Report Abuse |
|
|
| |
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 04 Dec 2011 06:37 AM |
Just use this in the character :P script.Parent.Humanoid.Died:connect(function() tag = script.Parent.Humanoid:findFirstChild("creator") if creator then if creator.Value then creator.leaderstats.Points.Value = creator.leaderstats.Points.Value + 10 end end end)
|
|
|
| Report Abuse |
|
|
Wil2
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 728 |
|
|
| 04 Dec 2011 09:48 AM |
@su8 FAIL!!!!!!! 2 reasons for the fail. 1. creator.leaderstats = errors 2. Object value can't be used to get something it's impossible. |
|
|
| Report Abuse |
|
|
Darkcheez
|
  |
| Joined: 22 Oct 2008 |
| Total Posts: 157 |
|
|
| 04 Dec 2011 10:16 AM |
| It has to be a feature of the weapons. Look in the rocket launcher, slingshot, or other default weapon. |
|
|
| Report Abuse |
|
|