#Changing Hint that says when someone is in the lead
1 messages · Page 1 of 1 (latest)
what does a hint mean like text in ui?
if so how are you keeping track how many kills each player has?
hold on
** You are now Level 1! **
it’s a script
Also, im trying to figure out how to do this specifically
umm
sorry if im confusing you, im still a bit new
no not that
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local intValue = Instance.new("IntValue")
intValue.Name = "KillCount"
intValue.Value = 0
intValue.Parent = player
end)
that keeps track of kills
Thank you so much
have you made the ui for it yet?
just keep all the kills in a dictionary or table probably
or that
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
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
project file if u have a hard time setting it up