Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local screenGui = playerGui:WaitForChild("ScreenGui")
- local playerNamesFrame = screenGui:WaitForChild("PlayerNamesFrame")
- local function getBeast()
- local players = game.Players:GetChildren()
- for i = 1, #players do
- if players[i]:FindFirstChild("TempPlayerStatsModule") and players[i].TempPlayerStatsModule:FindFirstChild("IsBeast") and players[i].TempPlayerStatsModule.IsBeast.Value == true or (players[i].Character ~= nil and players[i].Character:FindFirstChild("BeastPowers")) then
- return players[i]
- end
- end
- return nil
- end
- local function updatePlayerDistance(otherPlayer, beast)
- local playerName = otherPlayer.Name
- local playerNameLabel = playerNamesFrame:FindFirstChild(playerName .. "PlayerFrame")
- if playerNameLabel then
- local distanceLabel = playerNameLabel:FindFirstChild("DistanceLabel")
- if not distanceLabel then
- distanceLabel = Instance.new("TextLabel")
- distanceLabel.Name = "DistanceLabel"
- distanceLabel.Parent = playerNameLabel
- distanceLabel.Size = UDim2.new(0, 60, 1, 0)
- distanceLabel.BackgroundTransparency = 1
- distanceLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- distanceLabel.TextStrokeTransparency = 0.5
- distanceLabel.TextScaled = true
- distanceLabel.Text = "0"
- distanceLabel.Position = UDim2.new(0, -1, 0, 0)
- distanceLabel.AnchorPoint = Vector2.new(1, 0)
- distanceLabel.Font = Enum.Font.SourceSansBold
- distanceLabel.TextSize = 14
- end
- local humanoidRootPart = otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart")
- if humanoidRootPart then
- local distance = (humanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude
- distanceLabel.Text = math.floor(distance)
- if otherPlayer == beast then
- distanceLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
- else
- distanceLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- end
- end
- end
- end
- local function updateAllDistances()
- local beast = getBeast()
- for _, otherPlayer in ipairs(game.Players:GetPlayers()) do
- if otherPlayer ~= player then
- updatePlayerDistance(otherPlayer, beast)
- end
- end
- end
- game.Players.PlayerAdded:Connect(function(otherPlayer)
- updatePlayerDistance(otherPlayer, getBeast())
- end)
- game.Players.PlayerRemoving:Connect(function(otherPlayer)
- local playerFrameName = otherPlayer.Name .. "PlayerFrame"
- local playerFrame = playerNamesFrame:FindFirstChild(playerFrameName)
- if playerFrame then
- local distanceLabel = playerFrame:FindFirstChild("DistanceLabel")
- if distanceLabel then
- distanceLabel:Destroy()
- end
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(updateAllDistances)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement