I don't understand line 2 and 4. Also how does the use of parentheses work in this script, especially in line 2 and 6? Bonus question: what is the difference between CFrame and Vector3?
function onPlayerEntered(player)
player.CharacterAdded:connect(function(char) --Anonymous function fired when player's character loads
while wait() do -- Infinite loop!
script.Parent.CFrame = CFrame.new(char.Torso.Position) -- Tele to player's position
end
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered) -- connects function to PlayerAdded event.
UPDATE: Okay, this script was copied right out of ROBLOX's Scripting Book/Chapter 3: https://wiki.roblox.com/index.php?title=Scripting_Book/Chapter_3
I made an attempt of testing the script and it is not working. Yes, the script is placed under the part and the part is unanchored.

1 comment
before the word function, you can see a open parenthesis. In line 6, you use a close parenthesis to close the function