For some reason none of my prints actually print, the character’s accessories don’t get deleted, and leader stats don’t show.
local Players = game:GetService('Players')
local ServerScriptService = game:GetService('ServerScriptService')
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local ins = game:GetService("InsertService")
-------------------------
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("AVFSplrData")
-------------------------
local pf = Instance.new("Folder")
pf.Parent = workspace
pf.Name = "Game Players"
--------------------------Chat color TEST
ChatService.SpeakerAdded:Connect(function(PlayerName)
local Speaker = ChatService:GetSpeaker(PlayerName)
Speaker:SetExtraData('NameColor', Color3.fromRGB(209, 193, 97))
Speaker:SetExtraData('ChatColor', Color3.fromRGB(255, 191, 0))
Speaker:SetExtraData('Tags', {{TagText = 'DEV', TagColor = Color3.fromRGB(189, 83, 83)}})
Speaker:SetExtraData('Font', Enum.Font.Code)
Speaker:SetExtraData('TextSize', 20)
end)
-------------------------
function leaderstatsplr(plr)
local data
----///leaderstats
local l = Instance.new("Folder")
l.Parent = plr
l.Name = "leaderstats"
local fm = Instance.new("NumberValue")
fm.Name = "Flight Time"
fm.Parent = l
local r = Instance.new("StringValue")
r.Name = "Rank"
r.Parent = l
local success, err = pcall(function()
data = DS:GetAsync(plr.UserId)
end)
if success and data then
fm.Value = data[1]
else
fm.Value = 0
print(err)
end
end
function charadded(char)
print("charadded func ran")
for _,c in ipairs(char:GetDescendants()) do
if c:IsA("Accessory") or c:IsA("Decal") then
c:Destroy()
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
local newchar = plr.Character or plr.CharacterAdded:Wait()
print("new char")
leaderstatsplr(plr)
---------------------------
local p = Instance.new("Folder")
p.Name = plr.Name .. "_Fld"
p.Parent = game.Workspace:WaitForChild("Game Players")
local plrstuf = script.Parent.Parent.Cloned.AVFSplr:Clone()
plrstuf.Parent = plr
plr.CharacterAdded:Connect(function(char)
print("charadded")
if newchar then
print("charadded func started")
charadded(newchar)
end
end)
plr.CharacterRemoving:Connect(function(car2)
if newchar then
game.Workspace["Game Players"][plr.Name.."_Fld"]:ClearAllChildren()
end
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local savetable = {
plr.leaderstats:WaitForChild("Minutes Flown").Value
}
game.Workspace:WaitForChild("Game Players")[plr.Name .. "_Fld"]:Destroy()
DS:SetAsync(plr.UserId,savetable)
end)
Please Help