How can you make a win system that you have a kill goal to win a game?
COMMUNITY QUESTION
How can you make a win system that you have a kill goal to win a game?
1 answer
game.Players.PlayerAdded:connect(function(player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = player
local Level = Instance.new("IntValue")
Level.Name = "Kills"
Level.Value = 1
Level.Parent = Leaderstats
end)
If you would like it to save the ammount of kills the datasave could be done like this
function onPlayerEntered(player)
wait()
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end
function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)
1 comment
0
Like I mean that i already have a leaderboard i just need a win system like there is a time limit the game will end and the team with the most score will win.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Hello jnsan56. This would be possible by making a leaderstat for Kills. This can be achieved by using a plugin or making it I will post a answer for the leadersat now
This is not a request website. Please refrain from making us do all the scripting.