local D = game:GetService("DataStoreService"):GetDataStore("AI")
local HS = game:GetService("HttpService")
game.Players.PlayerAdded:connect(function(P)
wait(1)
local F = Instance.new("Folder")
F.Parent = P
F.Name = "Values"
local CV,NA = {
Money = "BoolValue","Money";
Axe = "BoolValue","Axe";
AppleCount = "NumberValue","AppleCount";
Bread = "NumberValue","Bread";
Bucket = "BoolValue","Bucket";
}
for i = 1,5 do
if CV == "BoolValue" then
local B = Instance.new("BoolValue").Parent == P.Values
B.Name = NA
elseif CV == "NumberValue" then
local N = Instance.new("NumberValue").Parent == P.Values
N.Name = NA
else print("Error")
end
local K = P.UserId
D:GetAsync("AI", K)
end
end)
After solving all the errors, for some reason "I = 1,5 do" Isn't actually creating the values. Is there something I did wrong around there?
What I'm basically trying to do is when the player joins the game, For each of CV,NA's values, they create a NumberValue or a BoolValue, depending on CV. then it's named according to NA.
The output when I run this code, just prints "Error".
But I've checked my "if" statements, and I don't understand why it's not confirming/Creating the instances according to CV....
Any help would be appreciated.

6 comments
youre looping through it wrong
You should indent your code correctly. http://wiki.roblox.com/index.php?title=Lua_Style_Guide#Whitespace_Rules
How am I looping through it wrong? and correctly? I thought putting .parent at the end of a instance would make the code shorter?
Try making variables more meaningful, instead of just like P for player. Also, where did you get CV from?
P is the acronym for player, though.
Normally I shorten Variable names to make the code look less... Messy, and shorten the lines of code so I can operate in a two-window mode. CV stands for Character Variables.