:

1. 🧍 When a player joins the game

(Server Script)

lua
CopyEdit
game.Players.PlayerAdded:Connect(function(player)
	-- code to run when a player joins
end)


3. 🧍‍♂️ Get the player who touched a part

(Server Script)

lua
CopyEdit
Part.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(character)

	if player then
		print("stfu")
	end
end)


4. 🧍‍♂️ Get the local player

(LocalScript only)

lua
local player = game.Players.LocalPlayer
-- use player for local UI, camera, etc.


5. 🧍‍♂️ Find a player by name

(Any script type)

lua
local player = game.Players:FindFirstChild("PlayerName")
if player then
	print("PlayerName")
end


🔁 Common Add-on: Get Character Safely

lua
CopyEdit
local character = player.Character or player.CharacterAdded:Wait()
-- now you can safely use character