I found this error where .CharacterAdded only runs in certain code lines..
Script Before:
game.Players.PlayerAdded:connect(function(plr)
local key = plr.UserId
-- WANT DATASTORE IF STATEMENT HERE. BUT CHARACTERADDED DOESNT RUN.
if DataStore:GetAsync(key) == nil then
--// New player data;
PlayerData[plr] = Default_Data
print(HttpService:JSONEncode(PlayerData[plr]))
else
--// Current Player Data; Wrapping in Pcall to find any errors.
local success, message = pcall(function()
wait(3)
PlayerData[plr] = HttpService:JSONDecode(DataStore:GetAsync(key));
end)
if not success then
print('Error: '..message)
else
print("Good.")
end
end
plr.CharacterAdded:Connect(function(Character)
print("LOL")
RagdollModule.EquipAccessories(plr, PlayerData[plr]["KnifeEquipped"])
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:Connect(function()
if GetIndex(CurrentPlayers, plr) ~= -1 then
table.remove(CurrentPlayers, GetIndex(CurrentPlayers, Player))
end
wait(4)
if plr then
plr:LoadCharacter()
end
end)
end
end)
print(plr.Name.." has joined")
local Level, Alpha = LevelModule.GetLevel(PlayerData[plr]["XP"])
--// Print Player Data
print(HttpService:JSONEncode(PlayerData[plr]))
end)
Script Now (when solved):
game.Players.PlayerAdded:connect(function(plr)
local key = plr.UserId
plr.CharacterAdded:Connect(function(Character)
print("LOL")
-- DATASTORE IF STATEMENT INSIDE CHARACTERADDED.
if DataStore:GetAsync(key) == nil then
--// New player data;
PlayerData[plr] = Default_Data
print(HttpService:JSONEncode(PlayerData[plr]))
else
--// Current Player Data; Wrapping in Pcall to find any errors.
local success, message = pcall(function()
wait(3)
PlayerData[plr] = HttpService:JSONDecode(DataStore:GetAsync(key));
end)
if not success then
print('Error: '..message)
else
print("Good.")
end
end
RagdollModule.EquipAccessories(plr, PlayerData[plr]["KnifeEquipped"])
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Died:Connect(function()
if GetIndex(CurrentPlayers, plr) ~= -1 then
table.remove(CurrentPlayers, GetIndex(CurrentPlayers, Player))
end
wait(4)
if plr then
plr:LoadCharacter()
end
end)
end
end)
print(plr.Name.." has joined")
local Level, Alpha = LevelModule.GetLevel(PlayerData[plr]["XP"])
--// Print Player Data
print(HttpService:JSONEncode(PlayerData[plr]))
end)
And even then it doesn't Print Line 12 for the Script(when solved) Is this a roblox error? Or is is just me scripting wrongly..
