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: Finding out who killed who?

Previous Thread :: Next Thread 
Noahk is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Noahk
Joined: 14 Feb 2008
Total Posts: 1460
09 Apr 2012 03:02 PM
Connection line:
player.Character.Humanoid.Died:connect(onDeath)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Apr 2012 03:04 PM
You didn't define player... how obvious is that?

† KMXD †
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Apr 2012 03:04 PM
OMGGGGGGG Juuuuuust kidding. :P

Stupid floodcheck
† KMXD †
Report Abuse
Noahk is not online. 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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Apr 2012 03:05 PM
Wait... I don't think you did it right...

† KMXD †
Report Abuse
Flurite is not online. 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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Apr 2012 03:06 PM
The connection line doesn't define it... Where is this script located?

† KMXD †
Report Abuse
Flurite is not online. 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 is not online. 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 is not online. Noahk
Joined: 14 Feb 2008
Total Posts: 1460
09 Apr 2012 03:28 PM
Help?
Report Abuse
TheDuckOfYork is not online. TheDuckOfYork
Joined: 07 Jan 2012
Total Posts: 6599
09 Apr 2012 03:31 PM
local killer = getKillerOfHumanoidIfStillInGame(humanoid)

handleKillCount(humanoid, player)
end
end

function onPlayerRespawn(property, player)
Report Abuse
Noahk is not online. Noahk
Joined: 14 Feb 2008
Total Posts: 1460
09 Apr 2012 03:34 PM
what
Report Abuse
Miro034 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
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