How would I save wins in a datastore for whoever survives a disaster in a minigame-like game?

  1. What do you want to achieve? I want to save whenever someone wins a match/survives a round of a disaster.

  2. What is the issue? Not sure how to do it.

  3. What solutions have you tried so far? I looked everywhere but nothing works witth my code…

Heres my main-game scripts

local lobbyLocation = game.Workspace.Lobby2.Position + Vector3.new(0,3,0)
local gameLocation = game.Workspace.Game.Position + Vector3.new(0,3,0)

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local timeEvent = ReplicatedStorage:WaitForChild('TimeEvent')

local tweenService = game:GetService("TweenService")
local Lava = game.Workspace.Other.Lava
local tweeninfo = TweenInfo.new(20,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local tweeninfo2 = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local move2 = {
	Position = Vector3.new(-0.049, 22.754, -5.795)
}
local move = {
	Position = Vector3.new(0, -43.124, -5.795)
}
local tween = tweenService:Create(Lava,tweeninfo2,move)
local tween2 = tweenService:Create(Lava,tweeninfo,move2)

local function playGame()
	tween2:Play()
	print("Game Started!")
	local timeAmount = 20
	local timerText = 'Game Time: '
	while timeAmount > 0 do
		timeEvent:FireAllClients(timeAmount, timerText)
		wait(1)
		timeAmount -= 1
	end
end

local function beforeGame()
	print("Game is Starting!")
	local beforeGame = 5
	local beforeText = 'Lava Starts In: '
	while beforeGame > 0 do
		timeEvent:FireAllClients(beforeGame, beforeText)
		wait(1)
		beforeGame -= 1
	end
end


local function playIntermission()

	tween:Play()
	print("Intermission has started!")
	local intermission = 3
	local timerText = ' '
	while intermission > 0 do
		timeEvent:FireAllClients(intermission, timerText)
		wait(1)
		intermission -= 1
	end
end



local function resetPlayers()
	print("Players have been reset!")
	for _, plr in pairs(game.Players:GetChildren()) do

		plr.Character.HumanoidRootPart.CFrame = CFrame.new(lobbyLocation)
	end 
end



local function teleportPlayers()
	print("Players were teleported!")
	for _, plr in pairs(game.Players:GetChildren()) do

		plr.Character.HumanoidRootPart.CFrame = CFrame.new(gameLocation)
	end 
end



while true do

	resetPlayers()

	playIntermission()

	teleportPlayers()

	beforeGame()

	playGame()

end
1 Like

Make an IntValue of wins (and probably parent it to the character or player), and whenever a player wins the minigame, increase that value by 1. You can save it in a datastore by just watching a youtube tutorial. I recommend watching this one:

(For this specific case, you can make a variable for each player, and whenever they die, set that variable to something else, and at the end of the minigame, use a table loop of every player’s variable to see who survived/died.)

1 Like