✓ Accepted answer
StarterGui is a folder that stores things to be given to the player - it does not control the actual GUIs the player is seeing. You will find that respawning updates the gui, because StarterGui will by default clear the player's PlayerGui, then clone StarterGui's content into it.
As well as this, this will update the GUI for all players, something which I believe you do not want to happen from look at your code.
Here's the fixed version of the code:
local part = workspace:WaitForChild("Part")
local playerScores = {}
part.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local gui = player.PlayerGui:FindFirstChild("ScreenGui")
if gui then
local text = gui:WaitForChild("TextLabel")
if not playerScores[player] then
playerScores[player] = 0
end
playerScores[player] = playerScores[player] + 1
text.Text = "Score:" ..playerScores[player]
end
end
end)
Hope I helped! If you need more help, please ask.
~TDP