#Need help setting up Kill Counter

27 messages · Page 1 of 1 (latest)

fallow sun
#

Hello there , i already have a "Death" script and a "StarterGui" created , now my Problem is that my "kills" just count in the "main" interface instead of the "Gui" i made and i have no idea how to fix this, can someone maybe help? 🙂

echo falconBOT
#

studio** You are now Level 2! **studio

gloomy oar
#

you mean ur leaderstats are going up but the gui isnt?

fallow sun
#

i want to increase the "counter" in my GUI instead of the "normal" one on the right side

gloomy oar
#

you'd need to run a loop inside the textlabel that says while wait() do script.Parent.Text = game.Players.LocalPlayer.leaderstats.Kills.Value end

fallow sun
#

inside the Gui or the death script?

gloomy oar
#

gui

#

inside the textlabel

fallow sun
#

i am currently running this

local killsLabel = game.StarterGui.KillsLabel.Kills

local function updateKills(player)
local kills = player:FindFirstChild("leaderstats") and player.leaderstats.Kills
if kills then
killsLabel.Text = "Kills: " .. kills.Value
end
end

game.Players.PlayerAdded:Connect(function(player)
updateKills(player)
player:GetPropertyChangedSignal("leaderstats"):Connect(function()
updateKills(player)
end)
end)

for _, player in ipairs(game.Players:GetPlayers()) do
updateKills(player)
end

gloomy oar
#

yeah maybe try player.leaderstats:GetPropertyChangedSignal("Kills")

fallow sun
#

u mean in this line?
player:GetPropertyChangedSignal("leaderstats"):Connect(function()
updateKills(player)

gloomy oar
#

if that doesnt work honestly just delete the script and do what i first said

#

cuz that 40 line script is doable in like 3 lines

fallow sun
#

so editing " player:GetPropertyChangedSignal("leaderstats"):Connect(function()
updateKills(player)" this

to

player.leaderstats:GetPropertyChangedSignal("Kills")
    updateKills(player)
gloomy oar
#

yes

fallow sun
#

checking

#

nope :/

#

still my Gui at 0 and regular interface at +1

#

local killsLabel = game.StarterGui.KillsLabel.Kills

local function updateKills(player)
local kills = player:FindFirstChild("leaderstats") and player.leaderstats.Kills
if kills then
killsLabel.Text = "Kills: " .. kills.Value
end
end

game.Players.PlayerAdded:Connect(function(player)
updateKills(player)
player:GetPropertyChangedSignal("leaderstats"):Connect(function()
updateKills(player)
end)
end)

for _, player in ipairs(game.Players:GetPlayers()) do
updateKills(player)
end

while true do
wait(1)
for _, player in ipairs(game.Players:GetPlayers()) do
updateKills(player)
end
end

hope i set the "loop" you talked before right but its still not working like this

gloomy oar
#

while wait() do script.Parent.Text = game.Players.LocalPlayer.leaderstats.Kills.Value
end

gloomy oar
#

it will update the text

fallow sun
#

fixed thanks a lot !! ❤️

gloomy oar
#

Yeah you're welcome

fallow sun
#

i spend almost 2 hours now before creating this thread 😄