Ad
Log in to vote
0

How can you make a win system that you have a kill goal to win a game?

Asked by
jnsan56 -10
10 days ago

How can you make a win system that you have a kill goal to win a game?

0
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 Pixelifix 10 — 10d
0
This is not a request website. Please refrain from making us do all the scripting. Phlegethon5778 63 — 9d

1 answer

Log in to vote
0
Answered by 10 days ago
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)

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. jnsan56 -10 — 10d
Ad

Answer this question