local player = game:GetService('Players').LocalPlayer
player.RespawnLocation = game.Workspace.SpawnLocation1
game.StarterGui.ScreenGui.TextLabel.Text = player.RespawnLocation.Name
Use WaitForChild; at the time the script runs, the Instance hasn’t been replicated to the client yet.
local player = game:GetService('Players').LocalPlayer
player.RespawnLocation = workspace:WaitForChild("SpawnLocation1")
-- When showing something on the player's screen, use PlayerGui, not StarterGui.
local screenGui = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
screenGui.TextLabel.Text = player.RespawnLocation.Name
Local scriprs run as soon as the player joins, before the things in workspace are replicated. Like the player said above me use :WaitForChild() so it ensures the part is loaded before proceeding.
Your new code:
local spawnLocation = workspace:WaitForChild("SpawnLocation2")