Hello, so i am freaking out on my datastore script showing this error: 3 is not a valid member of DataStoreService “DataStoreService”
i literally don’t understant where is the issue. i need help ASAP
Script:
local DataStore = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local MainData = DataStore:GetDataStore("MainData_4")
Players.PlayerAdded:Connect(function(Player)
Player:SetAttribute("DataReady", false)
local Folder = Instance.new("Folder", Player)
Folder.Name = "leaderstats"
local DataFolder = Instance.new("Folder", Player)
DataFolder.Name = "PlayerData"
local Val = Instance.new("IntValue", Folder)
Val.Name = "Level"
local Val1 = Instance.new("IntValue", DataFolder)
Val1.Name = "XP"
local Val2 = Instance.new("BoolValue", DataFolder)
Val2.Name = "Blood"
local Val3 = Instance.new("BoolValue", DataFolder)
Val3.Name = "Radio"
local Val4 = Instance.new("BoolValue", DataFolder)
Val4.Name = "Debug"
local Val5 = Instance.new("IntValue", DataFolder)
Val5.Name = "FOV"
local Val6 = Instance.new("NumberValue", DataFolder) --hit marker volume
Val6.Name = "HMV"
local Val7 = Instance.new("IntValue", DataFolder)--hit marker Sound Id
Val7.Name = "HMID"
local DataStats = MainData:GetAsync(Player.UserId)
print(DataStats)
if DataStats ~= nil then
Val.Value = DataStats[1]
Val1.Value = DataStats[2]
Val2.Value = DataStore[3]
Val3.Value = DataStore[4]
Val4.Value = DataStore[5]
Val5.Value = DataStore[6]
Val6.Value = DataStore[7]
Val7.Value = DataStore[8]
else
Val.Value = 0
Val1.Value = 0
Val2.Value = false
Val3.Value = true
Val4.Value = false
Val5.Value = 70
Val6.Value = 0.5
Val7.Value = 160432334
end
Player:SetAttribute("DataReady", true)
while wait(0.2) do
if Val1.Value >= (110 * (Val2.Value + 1)) then
local OldLevel = Val2.Value
Val1.Value = 0
Val2.Value = Val2.Value + 1
ReplicatedStorage.LevelUp:FireClient(Player, OldLevel, Val1.Value)
end
end
end)
Players.PlayerRemoving:Connect(function(Player)
local SaveTable = {}
table.insert(SaveTable, Player:FindFirstChild("leaderstats"):FindFirstChild("Level").Value) --1
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("XP").Value) --2
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("Blood").Value) --3
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("Radio").Value) --4
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("Debug").Value) --5
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("FOV").Value) --6
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("HMV").Value) --7
table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("HMID").Value) --8
--table.insert(SaveTable, Player:FindFirstChild("PlayerData"):FindFirstChild("").Value)
print(SaveTable)
MainData:SetAsync(Player.UserId, SaveTable)
end)