Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 02:30 PM |
I have a game, with a sword. I have a script that, when someone of a certain team dies, the script finds the killer and puts him on a different team. How would I go about doing this correctly?
I know the sword tags humanoids, but how would I access that from an external script? |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 02:32 PM |
| Use values (StringValues, NumberValues, etc) to transfer information between scripts. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 02:42 PM |
owahfpaiehf Can someone explain this to me as though I was five? |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 02:47 PM |
| Typical leaderboard does this just fine, can someone cut out part of that script? |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 02:49 PM |
Honestly I couldn't have said it any more simpler..
1. create a stringvalue dat memorises dah naim of dah killa 2. wen the person dies, u put the killas name into the stringvalue 3. frum anotha script can acess the name and do wateva u want with it 4. ??? 5. prawfit |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 02:54 PM |
Okay. The sword tags the humanoid. Can I just use that objectvalue? |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 02:56 PM |
| Wut? That doesn't make sense, but if it works, then go for it.. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 03:01 PM |
none of this makes sense. Well now, apparently I never defined 'player' Here's the code
function onDeath(player) local killer = game.Players:findFirstChild(""..player.Humanoid.Creator.Value"") local killerhealth = game.Workspace:findFirstChild(""..killer"") if player.TeamColor == "Bright Yellow" then killerhealth.Humanoid.Health = 0 player.TeamColor = BrickColor.new("Bright Blue") killer.TeamColor = BrickColor.new("Bright Yellow") end end
|
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 03:02 PM |
Connection line: player.Character.Humanoid.Died:connect(onDeath) |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2012 03:04 PM |
You didn't define player... how obvious is that?
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2012 03:04 PM |
OMGGGGGGG Juuuuuust kidding. :P
Stupid floodcheck † KMXD † |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 03:05 PM |
| Define player then. I thought the connection line does that. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2012 03:05 PM |
Wait... I don't think you did it right...
† KMXD † |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 03:05 PM |
That means you called your function incorrectly.. you have to look into that yourself. But there's also errors with the function, and why do you have random strings and concatenation operators at the end of stuff?
function onDeath(player) local killer = game.Players:findFirstChild(player.Humanoid.Creator.Value) local killerhealth = game.Workspace:findFirstChild(killer) if player.TeamColor == BrickColor.new("Bright Yellow") then killerhealth.Humanoid.Health = 0 player.TeamColor = BrickColor.new("Bright Blue") killer.TeamColor = BrickColor.new("Bright Yellow") end end |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2012 03:06 PM |
The connection line doesn't define it... Where is this script located?
† KMXD † |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 03:07 PM |
| I'm pretty sure the Died event implicitly gives the function connecting to it the character getting killed. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 03:08 PM |
Script is in workspace. Full code: print("Dominator game start") function playerEnter(player) wait(.5) if game.Players.NumPlayers == 1 then --could be glitchy, keep an eye open for tutorials player.TeamColor = BrickColor.new("Bright yellow") player.Character.Humanoid.MaxHealth = 350 end end
function onDeath(player) local killer = game.Players:findFirstChild(""..player.Humanoid.Creator.Value"") local killerhealth = game.Workspace:findFirstChild(""..killer"") if player.TeamColor == "Bright Yellow" then killerhealth.Humanoid.Health = 0 player.TeamColor = BrickColor.new("Bright Blue") killer.TeamColor = BrickColor.new("Bright Yellow") end end
function getKillerOfHumanoidIfStillInGame(humanoid) --ah -- 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
game.Players.PlayerAdded:connect(playerEnter) player.Character.Humanoid.Died:connect(onDeath) |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
| |
|
|
| 09 Apr 2012 03:31 PM |
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
handleKillCount(humanoid, player) end end
function onPlayerRespawn(property, player) |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
| |
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 09 Apr 2012 04:08 PM |
| I think you should insert Values, define them and define the value of it. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 04:18 PM |
| I dont know how to do any of that stuff. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 05:20 PM |
| If someone would just write this correctly it would be great. You don't need any other scripts, leaderboards use this method just fine. |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 09 Apr 2012 05:23 PM |
| There is so many things that are wrong with the script. I suggest you rewrite your own version. |
|
|
| Report Abuse |
|
|
Noahk
|
  |
| Joined: 14 Feb 2008 |
| Total Posts: 1460 |
|
|
| 09 Apr 2012 05:28 PM |
| I did, and It's been a year. Can someone just help me? D: I am at a total loss. |
|
|
| Report Abuse |
|
|