I know there is a lot of code, BUT there is ONE PART THAT IS NOT WORKING. The string value inside the players called personalsword is supposed to be 'LINKED' but only one out of all the players in test mode have the value 'LINKED'. In game, only one person has that and that one person gets two swords.

Can someone help me? Thank you.

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStorage")


--[[function TweenIncentive()
	for i, v in pairs(game.Players:GetPlayers()) do
		v.PlayerGui.PlayerScreenGui.LogInReward:TweenPosition(0, 600, 0, 0)
		wait(3)
		v.PlayerGui.PlayerScreenGui.LogInReward:TweenPosition(0, 2000, 0, 0)
		v.PlayerGui.PlayerScreenGui.LogInReward.Position = UDim2.new(0, -100, 0, 0)
	end
end]]
local StartingPoints = 500
local StartingLevel = 0
local DefaultSword = "Linked"

game.Players.PlayerAdded:connect(function(player)
	local key = "user_" .. player.userId
	


	game.Workspace.NumberIsInPlace.Value = game.Workspace.NumberIsInPlace.Value + 1
	

	--[[if player.Name == "JamaicaHolder" then
		player.Character.Humanoid.WalkSpeed = 30
		pl
	end]]

	local PlayerInf = Instance.new("Folder", player )
	PlayerInf.Name = "PlayerInfo"

	local stats = Instance.new("ObjectValue", player)
	stats.Name = "leaderstats" 
	
	local points = Instance.new("IntValue", PlayerInf)
	points.Name = "Player Points"
	
	local level = Instance.new("NumberValue", stats)
	level.Name = "Level"
	level.Value = "Linked"
	
	--[[if player.Name == "JamaicaHolder" then
		player:WaitForChild("Player Points").Value = 10000000000
	end]]
	
	local ingame = Instance.new("BoolValue", player)
	ingame.Name = "Ingame"

	

	local chosensword = Instance.new("StringValue", player)
	chosensword.Name = "PersonalSword"
	chosensword.Value = DefaultSword
	
	local thewins = Instance.new("IntValue", player)
	thewins.Name = "Wins"
	
	local streaknumber = Instance.new("IntValue", player)
	streaknumber.Name = "Streak"
	
	local GetSaved = DataStore:GetAsync(key)
	
	local Swords =  Instance.new("ObjectValue", player)
	Swords.Name = "Swords"
	
	local Items =  Instance.new("ObjectValue", player)
	Items.Name = "Items"
	
	
	local FreeLinked = Instance.new("BoolValue", Swords)
	FreeLinked.Name = "Linked"
	
	local IsInGame = Instance.new("BoolValue", player)
	IsInGame.Name = "GameBool"
	IsInGame.Value = true
	
	local DarkHeartSword = player.Swords:FindFirstChild("DarkHeart")
	local FireBrandSword = player.Swords:FindFirstChild("FireBrand")
	local GhostWalkerSword = player.Swords:FindFirstChild("GhostWalker")
	local IlluminaSword = player.Swords:FindFirstChild("Illumina")
	local VenomShankSword = player.Swords:FindFirstChild("VenomShank")
	local WindForceSword = player.Swords:FindFirstChild("WindForce")
	local SmallLinkedSword = player.Swords:FindFirstChild("SmallLinked")
	local LargeLinkedSword = player.Swords:FindFirstChild("LargeLinked")
	local swords = player.Swords
	
	local SavedLevel = DataStore:GetAsync(player.userId..'Level')
	local SavedSword = DataStore:GetAsync(player.userId..'PersonalSword')
	
	if SavedLevel ~= nil then
		level.Value = SavedLevel
	end
	
	if SavedSword ~= nil then
		chosensword.Value = SavedSword
	end
	
	if GetSaved then
		points.Value = GetSaved[1]
		thewins.Value = GetSaved[2]
		chosensword.Value = GetSaved[3]
		streaknumber.Value = GetSaved[4]
		swords = GetSaved[14]
		if DarkHeartSword then
		DarkHeartSword.Value = GetSaved[5]
		end
		if FireBrandSword then
		FireBrandSword.Value = GetSaved[6]
		end
		if GhostWalkerSword then
		GhostWalkerSword.Value = GetSaved[7]
		end
		if IlluminaSword then
		IlluminaSword.Value = GetSaved[8]
		end
		if VenomShankSword then
		VenomShankSword.Value = GetSaved[9]
		end
		if WindForceSword then
		WindForceSword.Value = GetSaved[10]
		end
		if SmallLinkedSword then
		SmallLinkedSword.Value = GetSaved[11]
		end
		if LargeLinkedSword then
		LargeLinkedSword.Value = GetSaved[12]
		end
		if FreeLinked then
			FreeLinked.Value = GetSaved[13]
		end
	
	
		
		--[[if os.time()-time > 86400 then
			TweenIncentive()
		else
			--24 hours has not passed
		end]]
		
	
		--[[
		local SaveSwords = player.Swords:GetChildren()
	for i, v in pairs(SaveSwords) do
		local NumbersForSaving = {points.Value,
			 thewins.Value,
			 chosensword.Value,
			 streaknumber.Value,
			 SaveSwords
			
			}
		DataStore:SetAsync(key, NumbersForSaving)
		end]]
	end
	
	--[[if Time > 43200 then
		player.leaderstats.Streak.Value = player.leaderstats.Streak.Value + 1
		TweenIncentive()
	end]]
	
	
end)




game.Players.PlayerRemoving:connect(function(player)
	game.Workspace.NumberIsInPlace.Value = game.Workspace.NumberIsInPlace.Value - 1
	local key = player.userId
	
	local SaveSwords = player.Swords:GetChildren()
	local LevelValue = player.leaderstats.Level.Value
	local SwordValue = player.PersonalSword.Value
	
	DataStore:SetAsync(key..'-Level', LevelValue)
	DataStore:SetAsync(key..'-PersonalSword', SwordValue)
	
	for i, v in pairs(SaveSwords) do
	local Savetable = {
		 player.leaderstats["Player Points"].Value,
		 player.Wins.Value,
		 player.PersonalSword.Value,
		 player.Streak.Value,
		 v.Value
		}
	DataStore:SetAsync(key, Savetable)
	end
end)

2 comments

0

Why is Swords an ObjectValue?

0

It's what is saved so that the player can choose a sword and serves as verification that the player has bought the sword. It's sort of a receipt.