How do I make a highest killstreak leaderstat? I tried looking some videos up and still haven't got any matching results. Can you help out? It's like whenever you get for example, 6 kills and then you die and the killstreak leaderstat goes to 6 and stays at 6 until you pass your streak record, then it goes over and over again the more you beat your streak record.
How do I make a highest killstreak leaderstat?
1 answer
I'm assuming you want some example code however before any of that I'll be explaining how to do it.
Basically, we create a folder called leaderstats and create two intvalues into the leaderstats. We parent the leaderstats into the Player so it creates a leaderboard. Shortly afterwards we make an event that fires every time the streak is changed, and we check if the streak's value is greater than the other intvalue ( the highest streak ). If that's the case we change the highest streak's value to the current streak's value.
game:GetService("Players").PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local Streak = Instance.new("IntValue")
Streak.Name = "Streak"
Streak.Value = 0
Streak.Parent = leaderstats
local BestStreak = Instance.new("IntValue")
BestStreak.Name = "Best Streak"
BestStreak.Value = 0
BestStreak.Parent = leaderstats
end)
We have some code above here with an event that fires every time the player joins. We have Player in the parameters so we can get the player that just joined. We declare three variables, one is a folder ( for the leaderstats ) and the others representing intvalues for both the streak and the best streak. Afterwards we will make another event that fires when the value of Streak is changed.
game:GetService("Players").PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local Streak = Instance.new("IntValue")
Streak.Name = "Streak"
Streak.Value = 0
Streak.Parent = leaderstats
local BestStreak = Instance.new("IntValue")
BestStreak.Name = "Best Streak"
BestStreak.Value = 0
BestStreak.Parent = leaderstats
Streak:GetPropertyChangedSignal("Value"):Connect(function()
if Streak.Value > BestStreak.Value then
BestStreak.Value = Streak.Value
end
end)
end)
We then make another event inside the playeradded event that monitors when the value of streak is changed. Once the event is fired we use a conditional statement to do basic arithmetic which is basically comparing both values of the streaks. If the Streak's value is greater than BestStreak's value then we set BestStreak's value to Streak's value.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Could you please describe what you mean by 'high' killstreak?
oh sorry i accidentally spelled it wrong, but its a HIGHEST streak in which you know, you reach your highest streak, and you need to get above that point to beat your highest record.