.touched help needed

It’s night and I’m a bit tired and I can’t figure out how to get this to print the plr touching the part’s name.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		print(plr.Name)
	end
end)

Your script doesn’t seem wrong. Another forum say when ever the part is touched, it only show that the player is touching, but dummy not. I think .Touched has a bug.

I tried his script and it does work

Where does the script located?

My script is inside of the part.

Try this instead

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print(hit.Parent.Name)
	end
end)

There’s not really a problem with the OP’s script, so either the script is not in the right place, or it’s disabled or the CanTouch is turned off

Alright, fixed it. My script needed to be in StarterCharacterScripts.

1 Like

You sure that Players is not renamed? Try getting the service

local Players = game:GetService("Players")

It’s my own game, I would know it…