I'm making a game where there are 2 teams, Survivors and Zombies, I want all players to be on the Survivors team to start with, and as npc's kill them, they join the Zombie team (work with the npc's).
My idea was to make a script that would work universally with every player but my problem is I do not know how to reference to the players humanoid as I do not know how to do it without using an exact username. I've looked at 30 tuts today to no avail and really need someone to show me what to do, I'd even let someone connect to my pc via team viewer. I'm keen about learning however I am really stuck. also, I wanted to make a score board where every time someone dies, the remaining survivors gain 1 point (like cod infection). Any help is appreciated, this is making me frustrated that I can't get it.
if game.Workspace.Player.Humanoid.Died and game.Players.
end
^^^ Your probably laughing at me rn but I've tried so many different things :(
In a server script
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") -- waits until Humanoid it finds Humanoid Humanoid.Died:connect(function(Died) local creator = Humanoid:FindFirstChild("creator") -- in a roblox already made sword script when the sword or whatever else it is hits the character it sets a StringValue in the humanoid if creator ~= nil then local AP = creato -- AP means AttackingPlayer TeamColor = AP.TeamColor Player.TeamColor = TeamColor -- set players team color to opponents end end) end) end)
Heres how the script works
1. Gets Player on startup
2. Gets Character after it gets Player
3. Gets humanoid after it gets Character
4. Makes a Died event for Humanoid
5. When Player dies it sets the Players TeamColor
to the opponents TeamColor