Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This error keeps popping up every time I test game. Can you Help Me fix it?

Here is the Error:
20:07:24.078 - ServerScriptService.Values:64: attempt to index nil with 'Name' 20:07:24.079 - Stack Begin 20:07:24.080 - Script 'ServerScriptService.Values', Line 64

here is the Script:`




local DataStoreService = game:GetService("DataStoreService")

local MyDataStore = DataStoreService:GetDataStore("myDataStore")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(player)
	local Values = Instance.new("Folder")
	Values.Name = "Values"
	Values.Parent = player
	

	local Item1Cost = Instance.new("NumberValue")
	Item1Cost.Name = "Item1Cost"
	Item1Cost.Parent = Values
	
	
	local Item1 = Instance.new("NumberValue")
	Item1.Name = "Item1"
	Item1.Parent = Values
	
	local Item2Cost = Instance.new("NumberValue")
	Item2Cost.Name = "Item2Cost"
	Item2Cost.Parent = Values
	
	
	local Item2 = Instance.new("NumberValue")
	Item2.Name = "Item2"
	Item2.Parent = Values
	
	local SellAmount = Instance.new("IntValue")
	SellAmount.Name = "SellAmount"
	SellAmount.Parent = Values
	
	local RebirthC = Instance.new("IntValue")
	RebirthC.Name = "RebirthC"
	RebirthC.Parent = Values
	
	local Setting1 = Instance.new("BoolValue")
	Setting1.Name = "Setting1"
	Setting1.Parent = Values
	
	local XP = Instance.new("IntValue")
	XP.Name = "XP"
	XP.Parent = Values
	
	local XPT = Instance.new("IntValue")
	XPT.Name = "XPT"
	XPT.Parent = Values
	
	local XPX2 = Instance.new("IntValue")
	XPX2.Name = "XPX2"
	XPX2.Parent = Values
	
	local XPTV = Instance.new("IntValue")
	XPTV.Name = "XPTV"
	XPTV.Parent = Values
	
	local NSL = Instance.new("IntValue")
	NSL.Name = "NSL"
	NSL.Parent = Values
	
	local CPBI Instance.new("IntValue")
	CPBI.Name = "CPBI"
	CPBI.Parent = Values
	
	local CPI = Instance.new("IntValue")
	CPI.Name = "CPI"
	CPI.Parent = Values
	
	local CPSI1 = Instance.new("IntValue")
	CPSI1.Name = "CPSI1"
	CPSI1.Parent = Values
	
	local CPSI1T = Instance.new("IntValue")
	CPSI1T.Name = "CPSI1T"
	CPSI1T.Parent = Values
	
	local SI1C = Instance.new("BoolValue")
	SI1C.Name = "SI1C"
	SI1C.Parent = Values
	
	local ValuesT = Values:GetChildren()
	print(ValuesT)


	
	local data
	local Data
	local Data1
	local Data2
	local Data3
	local Data4
	local Data5
	local Data6
	local Data7
	local Data8
	local Data9
	local Data10
	local Data11
	local Data12
	local Data13
	local Data14
	local Data15
	local success, errormessage = pcall(function()
		data = MyDataStore:getAsync(player.UserId.."-Item1Cost")
		Data = MyDataStore:getAsync(player.UserId.."-Item1")
		Data1 = MyDataStore:getAsync(player.UserId.."-SellAmount")
		Data2 = MyDataStore:getAsync(player.UserId.."-Item2Cost")
		Data3 = MyDataStore:getAsync(player.UserId.."-Item2")
		Data4 = MyDataStore:getAsync(player.UserId.."-RebirthC")
		Data5 = MyDataStore:getAsync(player.UserId.."-Setting1")
		Data6 = MyDataStore:getAsync(player.UserId.."-XP")
		Data7 = MyDataStore:getAsync(player.UserId.."-XPT")
		Data8 = MyDataStore:getAsync(player.UserId.."-XPX2")
		Data9 = MyDataStore:getAsync(player.UserId.."-XPTV")
		Data10 = MyDataStore:getAsync(player.UserId.."-NSL")
		Data11 = MyDataStore:getAsync(player.UserId.."-CPBI")
		Data12 = MyDataStore:getAsync(player.UserId.."-CPI")
		Data13 = MyDataStore:getAsync(player.UserId.."-CPSI1")
		Data14 = MyDataStore:getAsync(player.UserId.."-CPSI1T")
		Data15 = MyDataStore:getAsync(player.UserId.."-SI1C")
	end)
	if success then
		Item1Cost.Value = data
		Item1.Value = Data
		SellAmount.Value = Data1
		Item2Cost.Value = Data2
		Item2.Value = Data3
		RebirthC.Value = Data4
		Setting1.Value = Data5
		XP.Value = Data6
		XPT.Value = Data7
		XPX2.Value = Data8
		XPTV.Value = Data9
		NSL.Value = Data10
		CPBI.Value = Data11
		CPI.Value = Data12
		CPSI1.Value = Data13
		CPSI1T.Value = Data14
		SI1C.Value = Data15
		print("All Data Loaded")
	else
			print("there was an error saveing Data")
			warn(errormessage)
	end
	
	Item1Cost:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Item1Cost",player.Values.Item1Cost.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	Item1:GetPropertyChangedSignal("Value"):Connect(function()
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Item1",player.Values.Item1.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
		
	end)
	
	if Item1Cost.Value == 0 then
		Item1Cost.Value = 10
	end
	
	if SellAmount.Value == 0 then
		SellAmount.Value = 1
	end
	if Item2Cost.Value == 0 then
		Item2Cost.Value = 50
	end
	if RebirthC.Value == 0 then
		RebirthC.Value = 5000
	end
	if XPT.Value == 0 then
		XPT.Value = 10
	end
	if XPX2.Value == 0 then
		XPX2.Value = 1
	end
	if XPTV.Value == 0 then
		XPTV.Value = 1
	end
	if CPSI1.Value == 0 then 
		CPSI1.Value = 250
	end
	if CPSI1T.Value == 0 then
		CPSI1T.Value = 300
	end
	SellAmount:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-SellAmount",player.Values.SellAmount.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	Item2Cost:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Item2Cost",player.Values.Item2Cost.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	Item2:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Item2",player.Values.Item2.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	RebirthC:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-RebirthC",player.Values.RebirthC.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	Setting1:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Setting1",player.Values.Setting1.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	XPT:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-XPT",player.Values.XPT.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	XPX2:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-XPX2",player.Values.XPX2.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	XPTV:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-XPTV",player.Values.XPTV.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	NSL:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-NSL",player.Values.NSL.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	CPBI:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-CPBI",player.Values.CPBI.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	CPI:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-CPI",player.Values.CPI.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	CPSI1:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-CPSI1",player.Values.CPSI1.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	CPSI1T:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-CPSI1T",player.Values.CPSI1T.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
	SI1C:GetPropertyChangedSignal("Value"):Connect(function()
		
		local success, errormessage = pcall(function()
		MyDataStore:SetAsync(player.UserId.."-SI1C",player.Values.SI1C.Value)
	end)
	
	if success then
		print("Player Data Successfully Saved!")
	else
			print("There Was An Error When Saving")
			warn(errormessage)
	end
	
	
	end)
	
end)

2 comments

0

put your whole script in codeblock (lua button)

0

go to game.ServerScriptServices.Values, post that script as an answer (format it as code)

1 answer

I Found The Bug I had To Rewrite The line

	local CPBI = Instance.new("IntValue")
	CPBI.Name = "CPBI"
	CPBI.Parent = Values

IDK why I had to rewrite the line probably just a roblox studio's problem

1 comment

0

on line 51 local CPBI Instance.new("IntValue") you didnt put = so thats probably why

This discussion is preserved as it was. New answers, comments, and votes are closed.