All pastes #928327 Raw Edit

High Score

public lua v1 · immutable
·published 2008-03-04 23:13 UTC
rendered paste body
highscoreValue = "Max"hiscore = 0hiplayer = ""hint = Instance.new("Hint")hint.Text = "High Score:  Nobody!"hint.Parent = game.Workspacefunction onPlayerEntered(newPlayer)	local stats = Instance.new("IntValue")	stats.Name = "leaderstats"	local max = Instance.new("IntValue")	max.Name = highscoreValue	max.Value = 0	max.Parent = stats	wait(1)	stats.Parent = newPlayerendgame.Players.PlayerAdded:connect(onPlayerEntered)function getDistance(player)	local stats = player:FindFirstChild("leaderstats")	if stats ~= nil then		return stats[highscoreValue].Value	end	return 0endwhile true do	wait()	players = game.Players:GetChildren()	for i=1,#players do 		if getDistance(players[i]) > hiscore then			hiscore = getDistance(players[i])			hiplayer = players[i].Name		end	end	if hiplayer ~= nil then		hint.Text = "High Score:  "..hiplayer.." with ".. hiscore.."!"	endend