So I am making a Roblox 3rd Person shooter game and I have a leaderboard script in ServerScriptStorage which has this code
local Players = game.Players
local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'
Instance.new('IntValue', Template).Name = "Kills"
Instance.new('IntValue', Template).Name = "Deaths"
Players.PlayerAdded:connect(function(Player)
wait(1)
local Stats = Template:Clone()
Stats.Parent = Player
local Deaths = Stats.Deaths
Player.CharacterAdded:connect(function(Character)
Deaths.Value = Deaths.Value + 1
local Humanoid = Character:FindFirstChild "Humanoid"
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
local Killer = Child.Value
if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
local Kills = Killer.leaderstats.Kills
Kills.Value = Kills.Value + 1
end
end
return -- Only one player can get a KO for killing a player. Not 2, not 3. Only one.
end
end
end)
end
end)
end)
So at the very end I am trying to get if kills = 30 then run a code.. here's my attempt
if kills == 30 then
--Runs a code for example
print("Worked")
but it didn't work and I am not a roblox engineer I am a newbie at scripting so don't just give me a code and expect me to understand it

1 comment
you need some kind of loop that constantly checks to see if kills == 1