#Changing Hint that says when someone is in the lead

1 messages · Page 1 of 1 (latest)

hybrid palm
#

I have a hint, but I want it to change for everytime someone is in the lead with a certain amount of kills, it says “(Player here) is in the lead with (Kills here)
Any help?

cedar gust
cedar gust
hybrid palm
edgy blazeBOT
#

studio** You are now Level 1! **studio

hybrid palm
#

it’s a script

hybrid palm
cedar gust
#

umm

hybrid palm
#

sorry if im confusing you, im still a bit new

cedar gust
#

no not that

cedar gust
#

that keeps track of kills

hybrid palm
#

Thank you so much

cedar gust
#

have you made the ui for it yet?

willow nebula
#

just keep all the kills in a dictionary or table probably

cedar gust
#

or that

willow nebula
#

every time someone gets a kill run a check for if they have the most

#

if they do just make a function that updates text on the ui

#

to change it to the players name and kill counts

#

youll have both in the table

cedar gust
#
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local UpdateUI = game.ReplicatedStorage.UpdateUI

Players.PlayerAdded:Connect(function(player)
    local intValue = Instance.new("IntValue")
    intValue.Name = "KillCount"
    intValue.Value = 0
    intValue.Parent = player
end)

local highest = -1

local highestPlayer = nil

RunService.Heartbeat:Connect(function()
    local highest = -1
    local highestPlayer = nil

    for _, player in pairs(Players:GetPlayers()) do
        local killCount = player:FindFirstChild("KillCount")
        if killCount and killCount.Value > highest then
            highest = killCount.Value
            highestPlayer = player
        end
    end
    
    if highestPlayer then
        local text = highestPlayer.Name .. " is in the lead with " .. highest .. " kills"
        UpdateUI:FireClient(highestPlayer, "killcount", text)
    end
end)
#

server script ^^^^^^^^^^^^

#
local UpdateUI = game.ReplicatedStorage.UpdateUI

game.ReplicatedStorage.UpdateUI.OnClientEvent:Connect(function(type, text)
    local player = game.Players.LocalPlayer
    local label = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("TextLabel")
    
    if type == "killcount" then
        
        label.Text = text
    end
end)

client script^^^^^^^^^

#

make sure to add a remoteevent named UpdateUI

#

you would still need to add code for updating the kill count when you kill someone idk how ur going to do that so i didnt add it

willow nebula
#

Dont make the code for people

#

Or they wont learn

#

Give them directions/ideas on how to do it

#

So they go out research and actually learn how to make it