local hum = script.Parent:WaitForChild("Humanoid")
hum.Died:Connect(function()
local tag = hum:FindFirstChild("creator")
if tag then
local player = tag.Value
local kills = player.leaderstats.Kills
local streak = player.leaderstats.Streak
local maxstreak = player.MaxStreak
kills.Value += 1
streak.Value += 1
if maxstreak.Value > streak.Value then
maxstreak.Value += 1
end
end
end)
basically, when a player gets a kill, there are 3 values that are changed
-Kills (the total amount of kills they have)
-Streak (the current kill streak they are on, resets after they die)
-Max Streak (the highest streak they have ever reached before dying)
The problem is, the Max Streak is going up by +1, even if i have never actually reached that streak, it just goes up with every kill. I only want it to display the highest kill streak the player has reached
if streak.Value > maxstreak.Value then
maxstreak.Value += 1
end
The reason your code doesnt work is because if maxstreak.Value > streak.Value then is always true. If your current kill streak was 2 and the max kill streak was 3, this is what your asking the code to do: 3 > 2 which is true.
So try the code above and see if it works. Good luck on making your game!
Hello, thank you for your response. I tried your code but for some reason, it is still increasing ‘MaxStreak’ despite it not being the highest amount as before
For example, I die with 6 streak and my Streak is set to 0, I get a kill and my streak goes to 1, but my maxstreak goes to 7 now
The code is currently checking if the maxstreak.Value is greater than the streak.Value , which will always be true if the maxstreak.Value is initially set to 0.
you need to change the conditional statement to check if the streak.Value is greater than the maxstreak.Value
local hum = script.Parent:WaitForChild("Humanoid")
hum.Died:Connect(function()
local tag = hum:FindFirstChild("creator")
if tag then
local player = tag.Value
local kills = player.leaderstats.Kills
local streak = player.leaderstats.Streak
local maxstreak = player.MaxStreak
kills.Value += 1
streak.Value += 1
if streak.Value > maxstreak.Value then
maxstreak.Value = streak.Value
end
end
end)
local hum = script.Parent:WaitForChild("Humanoid")
hum.Died:Connect(function()
local tag = hum:FindFirstChild("creator")
if tag then
local player = tag.Value
local kills = player.leaderstats.Kills
local streak = player.leaderstats.Streak
local maxstreak = player.MaxStreak
kills.Value += 1
streak.Value += 1
if maxstreak.Value > streak.Value then
maxstreak.Value += 1
end
print(maxstreak.Value, streak.Value)
end
end)