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

How would i make a script so when a player dies it will make it turn into a ghost?

Here is the script (IN LOCALSCRIPT)

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			if Player:FindFirstChild("BodyColors")then --Detect the body colors of the player that died
				Player.BodyColors.HeadColor = "Mid gray"
				Player.BodyColors.LeftArmColor = "Light stone gray"
				Player.BodyColors.LeftLegColor = "Medium stone gray"
				Player.BodyColors.RightArmColor = "Medium stone gray"
				Player.BodyColors.RightLegColor = "Mid gray"
				Player.BodyColors.TorsoColor = "Light stone grey" 
			end
		end)
	end)
end)

2 answers

✓ Accepted answer

The way you changed the body colors is wrong, this is how you do it:

player.Head.BrickColor = BrickColor.new("Mid gray")
--It's "player" and not "Player" because this is what you used as argument (capitalization matters)

If you want to make it look more like a ghost you need to change the transparency:

player.Head.Transparency = 0.5

Do this with the rest of the body parts and the player will look like a ghost.

Use this instead:

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
			Player:LoadCharacter()
            if character:FindFirstChild("BodyColors") then --Detect the body colors of the player that died
                character.BodyColors.HeadColor = "Mid gray"
                character.BodyColors.LeftArmColor = "Light stone gray"
                character.BodyColors.LeftLegColor = "Medium stone gray"
                character.BodyColors.RightArmColor = "Medium stone gray"
                character.BodyColors.RightLegColor = "Mid gray"
                character.BodyColors.TorsoColor = "Light stone grey" 
            end
        end)
    end)
end)

Also, put it inside a normal script, not a LocalScript. You might want to make the character transparent. If so, you can turn its parts' Transparency to 0.5 or something.

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