Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Stats Gui is not showing the amount of kills? [Please Answer]

So I was working on a Stats Gui for the player to see how many kills and how much EXP they have. I'm not sure what I scripted was correct and I can't seem to define the variable for kills. So can I be assisted?

local player = game.Players.LocalPlayer
local kills = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills

kills.Changed:connect(function()
	if player:FindFirstChild('leaderstats') then
	script.Parent.Text = 'Kills: ' .. kills.Value
	end
end)

Here're some screenshots I took to show you, https://gyazo.com/ac32de91f85833b48944abbe4fa72d26 https://gyazo.com/14df459ffd8e5763d8e7a23461c8c8f2

1 comment

1

replace script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills with game.Players.LocalPlayer:WaitForChild("leaderstats"):FindFirstChild("Kills").

1 answer

✓ Accepted answer

Hello. First of all, please don't add clickbait to your title such as "[Please Answer]". It does not make the chances of you getting a response any higher.

Second, your variable for kills is overly complex. You can shorten it to player.leaderstats.Kills, I imagine. However, your problem seems to be you're asking for it too quickly. If you change it to player:WaitForChild("leaderstats"):WaitForChild("Kills"), it should work (assuming that long list of script.Parents leads to the local player)

This discussion is preserved as it was. New answers, comments, and votes are closed.