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

Can anyone tell me what i did wrong?

Asked by 9 years ago

~~~~~~~~~~~ target = game.Players

function onPlayerRespawned() target.Head.face.Texture = "" end

script.Parent.MouseButton1Click:connect(onPlayerRespawned)

~~~~~~

~~~~~~~~~~~~~~~~~ i'm trying to make when u enter the game or respawn it removes player's face

1 answer

Log in to vote
0
Answered by 9 years ago

Okay, you have a few problems here. First of all, you are targeting the Players category, not all of the players. To select the player, you would either have to use the player parameter of functions, or use LocalPlayer in a LocalScript. In this case, I will be using the player parameter. Second of all, you want the player's face to change when they respawn, but your connection line makes it run the function when they click a button. Try out this code, I will explain it in comments:

target = game.Players:GetChildren() --Sets the target to everyone in the Players area of the game.
function onPlayerRespawned(player)
    wait(6) --Waits 6 seconds after they die
    repeat wait() until player.Character and player.Character.Head.Face --Waits until the player's character and the player's face loads.
    player.Character.Head.Face:Destroy() --Destroys the face.
end

player.Died:connect(onPlayerRespawned) --As far as I know, there is no way to check when a player respawns in a connection line, so I had it run when they died, then wait 6 seconds so that their character reloads.
game.Players.PlayerAdded:connect(onPlayerRespawned) --Runs the function when a player joins

Ad

Answer this question