Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
6 years ago
Edited 6 years ago

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!

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 `TeamColor`s, or `BrickColor`s, so in that example you'd want to use `BrickColor.new('Really red')`. Good job otherwise. :) TheeDeathCaster 2368 — 6y
0
Ah true I didn't notice that, thx OfcPedroo 396 — 6y
0
There, I credited ya. Thx very much OfcPedroo 396 — 6y
0
So this script makes the killer become god? Skyraider5 -21 — 6y
View all comments (29 more)
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? Skyraider5 -21 — 6y
0
Sorry, by "he" I mean the previous God, the one that got killed not the new one. Skyraider5 -21 — 6y
0
sure. OfcPedroo 396 — 6y
0
ok Skyraider5 -21 — 6y
0
but can you mark this answer as the solution? #rep =] OfcPedroo 396 — 6y
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? Skyraider5 -21 — 6y
0
you have to specify the person who died. OfcPedroo 396 — 6y
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? Skyraider5 -21 — 6y
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. OfcPedroo 396 — 6y
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. Skyraider5 -21 — 6y
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? Skyraider5 -21 — 6y
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. Skyraider5 -21 — 6y
0
no, it will only put the Mortal Hero on the Gods team if he kills a GOD. Look at line 11. OfcPedroo 396 — 6y
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 Skyraider5 -21 — 6y
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 OfcPedroo 396 — 6y
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? Skyraider5 -21 — 6y
0
yeah, probably better I think thx OfcPedroo 396 — 6y
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. Skyraider5 -21 — 6y
0
ok. OfcPedroo 396 — 6y
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? Skyraider5 -21 — 6y
0
sure. i sent you a friend request. OfcPedroo 396 — 6y
0
ok thanks Skyraider5 -21 — 6y
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. Skyraider5 -21 — 6y
0
ok. OfcPedroo 396 — 6y
0
"You haven't been invited to edit any games" :'( #rejected xD OfcPedroo 396 — 6y
0
I just did it, check again Skyraider5 -21 — 6y
0
Dude where are you? Skyraider5 -21 — 6y
0
Hey Ofc you there? Skyraider5 -21 — 6y
0
OfcPedroo, you there? I have to tell you something, I have made a HUGE amount of progress on the game Skyraider5 -21 — 6y
Ad

Answer this question