Another script may be affecting the leaderstat, because I’ve tried the same exact script you posted here in studio and it worked completly fine. Feel free to post any other scripts you think may be doing this!
When you kill nothing happens because you’re only actually changing the levels when the player joins the game. You need to make it so eveytime the Death leaderstat changes or the Kill leaderstat changes the script checks if the levels can also be changed!
function ApplyLevel(player) -- Function for updating the levels of the player argument
local score = player.leaderstats.Kill.Value - player.leaderstats.Death.Value
if score < 0 then
player.leaderstats.Level.Value = "BRONZE"
elseif score > 49 and score <= 199 then
player.leaderstats.Level.Value = "GOLD"
elseif score >=200 and score <=399 then
player.leaderstats.Level.Value = "DIAMOND"
elseif score >=400 and score <=799 then
player.leaderstats.Level.Value = "MASTER"
elseif score >=800 then
player.leaderstats.Level.Value = "CHALLENGER"
end
end
game.Players.PlayerAdded:Connect(function(player) --게임속에 플레이어가 접속하면 함수 실행
local ls = Instance.new("Folder",player)
ls.Name = "leaderstats"
local Money = Instance.new("NumberValue")
Money.Parent = ls
Money.Value = 0
Money.Name = "Money"
local Kill = Instance.new("NumberValue")
Kill.Parent = ls
Kill.Value = 0
Kill.Name = "Kill"
local Death = Instance.new("NumberValue")
Death.Parent = ls
Death.Value = 0
Death.Name = "Death"
local Level = Instance.new("StringValue")
Level.Parent = ls
Level.Value = "SILVER"
Level.Name = "Level"
ApplyLevel(player) -- Apply the levels at the start of the game
Kill:GetPropertyChangedSignal("Value"):Connect(function()
ApplyLevel(player) -- When the value of Kill changes, apply levels again
end)
Death:GetPropertyChangedSignal("Value"):Connect(function()
ApplyLevel(player) -- When the value of Death changes, apply levels again
end)
end)