:
(Server Script)
lua
CopyEdit
game.Players.PlayerAdded:Connect(function(player)
-- code to run when a player joins
end)
(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)
(LocalScript only)
lua
local player = game.Players.LocalPlayer
-- use player for local UI, camera, etc.
(Any script type)
lua
local player = game.Players:FindFirstChild("PlayerName")
if player then
print("PlayerName")
end
lua
CopyEdit
local character = player.Character or player.CharacterAdded:Wait()
-- now you can safely use character