First of all, I’d like to say this is my first time using datastore2 so I’m still trying to figure some things out with it. Anyway on to my problem.
In my main script which I use datastore2 in everything works fine. I am able to use data anyway I want. In my second script I’m trying to get one table that I saved in the first script, but the problem is whenever I use it I get this error
[ServerScriptService.NameTags:44: attempt to index nil with ‘Equipped’
11:17:30.150 - Stack Begin
[11:17:30.150 - Script ‘ServerScriptService.NameTags’, Line 44]
11:17:30.151 - Stack End
I’ve already looked at the documentation again and unless I’m missing something I can’t find my problem, as well as I used this to try to help me-
Here are the important parts of my main script
local players = game:GetService("Players")
local dataStore2 = require(1936396537)
dataStore2.Combine("MasterKey", "StageStore", "DeathStore", "CoinsStore", "DiamondsStore", "SwordSave", "StagesStore", "NameTags")
local function setUpNameTags()
local nameTags = {
["Black"] = {
["Owned"] = true,
["Equipped"] = true
},
["Rainbow"] = {
["Owned"] = false,
["Equipped"] = false
},
["Gold"] = {
["Owned"] = false,
["Equipped"] = false
},
["White"] = {
["Owned"] = false,
["Equipped"] = false
}
--add as many as you want - arrow
}
return nameTags
end
local function onPlayerAdded(player)
if player then
print("player.Name")
local stageStore = dataStore2("StageStore", player)
local deathStore = dataStore2("DeathStore", player)
local coinsStore = dataStore2("CoinsStore", player)
local diamondsStore = dataStore2("DiamondsStore", player)
local OwnedSwords = dataStore2("SwordSave", player):Get(setUpSwords())
local StagesStore = dataStore2("StagesStore", player)
local stagesTable = StagesStore:Get(setUpStages())
local nameTags = dataStore2("NameTags", player)
local tagsTable = nameTags:Get(setUpNameTags())
--other stuff
end
end
players.PlayerAdded:Connect(onPlayerAdded)
at the moment I don’t use it anywhere else in the script
This is my other script.
local MarketPlaceService = game:GetService("MarketplaceService")
local datastore2 = require(1936396537)
local nameTag = game.ServerStorage:WaitForChild("NameTag")
local playerRole = game.ServerStorage:WaitForChild("playerRole")
local tweenService = game:GetService("TweenService")
local tagChange = game.ReplicatedStorage:WaitForChild("TagChange")
NameTagColors = {
["Black"] = 0, 0, 0,
["White"] = 255, 255, 255,
["Gold"] = 225, 211, 7,
["Rainbow"] = {
BrickColor.new("Steel blue").Color,
BrickColor.new("Bright violet").Color,
BrickColor.new("Magenta").Color,
BrickColor.new("Neon orange").Color,
BrickColor.new("Bright yellow").Color,
BrickColor.new("Lime green").Color,
BrickColor.new("Toothpaste").Color
}
}
local owner = "ix_Eclipse"
local staff = {
"arrowman888",
"KaylaGoesBoo"
}
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local playerTags = datastore2("NameTags", plr)
local NewTag = nameTag:Clone()
NewTag.TextLabel.Text = plr.Name
NewTag.Parent = char
if playerTags["Rainbow"]["Equipped"] == true then -- LINE 44
while true do
for i, v in ipairs(NameTagColors["Rainbow"]) do
ColorChange(v)
end
end
elseif playerTags["Gold"]["Equipped"] == true then
NewTag.TextLabel.TextColor3 = Color3.fromRGB(NameTagColors["Gold"])
elseif playerTags["White"]["Equipped"] == true then
NewTag.TextLabel.TextColor3 = Color3.fromRGB(NameTagColors["White"])
end
if MarketPlaceService:UserOwnsGamePassAsync(plr.UserId, 9020155) and plr.Name ~= owner then
local NewplayerRole = playerRole:Clone()
NewplayerRole.TextLabel.Text = "VIP"
NewplayerRole.TextLabel.TextColor3 = Color3.fromRGB(225, 211, 7)
NewplayerRole.Parent = char
end
if plr.Name == owner then
NewTag.TexTLabel.TextColor3 = Color3.fromRGB(0,0,0)
local NewplayerRole = playerRole:Clone()
NewplayerRole.TextLabel.Text = "Owner"
NewplayerRole.TextLabel.TextColor3 = Color3.fromRGB(225, 211, 7)
NewplayerRole.Parent = char
end
for i, v in ipairs (staff) do
if plr.Name == v then
NewTag.TextLabel.TextColor3 = Color3.fromRGB(0,0,0)
local NewplayerRole = playerRole:Clone()
NewplayerRole.TextLabel.Text = "Staff"
NewplayerRole.TextLabel.TextColor3 = Color3.fromRGB(33, 143, 33)
NewplayerRole.Parent = char
end
end
end)
end)
I’m thinking I might need to add the dictionary from my main script into my second script? That’s the only thing I can think of, but I feel like that would be a lot of un needed space wasted.
I tried doing this with a different system, but couldn’t figure it out, so I gave up and added it to the main script. I feel like it’s something obvious that I’m missing so if anyone could help me I’d give thanks.