Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make it so that when a player kills someone they respawn on another team?

Hey, I am making a game where there are three teams, Gods, Mortals, and Mortal Heroes. In the game, there can only be one player on the Gods team at a time and after the God dies, he respawns as a mortal. I have already made a working script for both of those things. Now I need help making a script that will make it so that if someone on the Mortal Heroes team (or any team really) kills the player on the Gods team, then the player on the Mortal Heroes team that killed the player on the Gods team will respawn on the Gods team. Does anyone know how I can do this?

Team Colors (In case you need them): Gods = Lapis Mortals = New Yeller Mortal Heroes = Really Red

If you have any other questions you can either post them in the comments section or message me on Roblox, I will check both and try to respond as soon as possible.

Thanks, Skyraider5

1 answer

It's easy peezy!

Following TheeDeathCaster's flaws on my previous script version, I updated the script.

Try the following:

local matchTeam = game.Teams["Mortal Heroes"] --If it's MortalHeroes instead of Mortal Heroes, please fix the variable with "game.Teams.MortalHeroes"

Players = Game:GetService("Players")
Players.PlayerAdded:connect(function(Player)
    --// You can add other stuff here, too.
    Player.CharacterAdded:connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:connect(function()
            if Player.Team = game.Teams.Gods then
                Player.Team = matchTeam
            end
            if Humanoid:FindFirstChild("creator") ~= nil then -- Checks for a Killed
                local Killer = Humanoid.creator.Value -- Gets Killer
                if Killer.Team== matchTeam then
                    Killer.Team = game.Teams.Gods
                end
            end
            end)
        end)
end)

If this works, please mark as the solution!

As always, good scripting!

33 comments

0

Line 9 wouldn't work: Using '=' tells the script that you're trying to set a value. I /think/ it's better to use '==' to compare values. XP Also, TeamColor takes other TeamColors, or BrickColors, so in that example you'd want to use BrickColor.new('Really red'). Good job otherwise. :)

0

Ah true I didn't notice that, thx

0

There, I credited ya. Thx very much

0

So this script makes the killer become god?

0

Ok great I'll test it, and where it says --For the Dead dude, you can do stuff to him here I can make it so that he is put on the mortals team?

0

Sorry, by "he" I mean the previous God, the one that got killed not the new one.

0

sure.

0

ok

0

but can you mark this answer as the solution? #rep =]

0

Sure, one I have seen if it works. One more question about this, If I write a script in the section that says -- For the Dead dude, you can do stuff to him here. will that script only effect the person who just died or will I have to specify that in the script?

0

you have to specify the person who died.

0

This doesn't actually say anything about the God team, only specifies the Mortal Heroes team, so how does it know to only work if a mortal hero has killed the god? Where does it say that the person who died was on the Gods team?

0

Skyraider it doesn't talk about the God team, but talks about its teamColor, on line 12, which would change player's team to teamcolor. But I just updated the script so you'll be more comfy. Repaste.

0

Well, what I am trying to do is make it so that not only does the Mortal hero who killed the god reset and become god but I also want to add a part that makes the God who was killed respawn as a Mortal.

0

My question wasn't referring to line twelve because that is the part that makes the killer the god. My question was referring to the fact that it doesn't say anywhere that the person who died was the God. That is why I am trying to add a part that causes the God to respawn as a mortal (not mortal hero, just plain Mortal). Where would I add this and or what would it look like in this script?

0

Also, since it doesn't say anywhere that the Mortal Hero has to kill the God to become god, does this script allow them to kill anyone, no matter what team they are on, and become god? Because the only way they should become God is if they kill the current God, not just anybody.

0

no, it will only put the Mortal Hero on the Gods team if he kills a GOD. Look at line 11.

0

well I just tested it and for whatever reason it is not working, no part of it is, the god stays as god once he dies and the mortal hero doesn't reset after he kills the God or become god

0

:S that's pretty strange. I would like to test it myself and keep editing until it would work, but I have no one to test it with :S

0

ok well I can test it with you in a couple of hours, I'll let you know when, but also if it still doesn't work I can uncopylock it and you can look over it and try to find out why it isn't working. Want me to do that?

0

yeah, probably better I think thx

0

OK, so in a few hours I'll just tell you here when I can test with you, and we can test it and then I'll uncopylock it and you can look around and help me figure out what is wrong with it.

0

ok.

0

Actually, can you friend me on roblox because I realized then we could do it over Team Create, so I could share the game with you and we could both edit it together at the same time, It'll be much easier ok?

0

sure. i sent you a friend request.

0

ok thanks

0

Ok, I can edit now, I'll invite you to edit in team create. Just open studio and click the tab that say shared with me and the game is called Gods VS Mortals.

0

ok.

0

"You haven't been invited to edit any games" :'( #rejected xD

0

I just did it, check again

0

Dude where are you?

0

Hey Ofc you there?

0

OfcPedroo, you there? I have to tell you something, I have made a HUGE amount of progress on the game

This discussion is preserved as it was. New answers, comments, and votes are closed.