function OnPlayerEntered(player)
humanoid = player.Parent:FindFirstChild("Humanoid")
if humanoid then
game.Players:GetPlayerFromCharacter(player)
player.Character.Torso.Transparency = 0.5
end
end
game.Players.PlayerAdded:Connect(OnPlayerEntered)
Line 2 is your error. The Parent of a Player
object is the Workspace, so what you're really doing is finding a nil Humanoid
in the Workspace, which causes FindFirstChild()
to return nil. The Humanoid
is always a child of the player's Character:
local humanoid = player.Character:FindFirstChild("Humanoid")
Additionally, if your game allows R15 rigs (R15 avatars), Torso
will not work because there is an UpperTorso
and a LowerTorso
.
Assuming your game allows R15:
local function OnPlayerEntered(player) local humanoid = player.Character:FindFirstChild("Humanoid") if humanoid then player.Character.UpperTorso.Transparency = 0.5 player.Character.LowerTorso.Transparency = 0.5 end end game.Players.PlayerAdded:Connect(OnPlayerEntered)
Assuming your game allows R6 but not R15:
local function OnPlayerEntered(player) local humanoid = player.Character:FindFirstChild("Humanoid") if humanoid then player.Character.Torso.Transparency = 0.5 end end game.Players.PlayerAdded:Connect(OnPlayerEntered)