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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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.

Ad
Log in to vote
0
Answered by
gskw 1046 Moderation Voter
9 years ago

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.

Answer this question