Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by
jnsan56 -31
6 years 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 ZapherosX 43 — 6y
0
This is not a request website. Please refrain from making us do all the scripting. User#21908 42 — 6y

1 answer

Log in to vote
-1
Answered by 6 years 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 -31 — 6y
Ad

Answer this question