Hello everyone, this is my second post here, and i have another question How do i print out the players name, yes i know this is pretty easy, but i tried some methods, it did not work, it always said: attempt to index nil with Name heres the script, i made a lava-like part, that kills you, and will print out the victims name
local lava = script.Parent -- making the lava variable
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local function killPlayer(otherPart) --the otherPart is what the object got touched with, a player touched the object with right foot,and then the script checks if its from a humanoid
local partParent = otherPart.Parent
local human = partParent:FindFirstChild("Humanoid")
human = partParent:WaitForChild("Humanoid")
if human.Health == 0 then
print("player is dead:", player.Name)
end
if human then
human.Health = 0
end
end
lava.Touched:Connect(killPlayer)
(you might also tip me some scripting tips)

3 comments
Change it to print("player is dead:" .. Player.Name) in line 14
Thanks alot, this worked, and i will remember this
No probs