everythings working but the playerRemoving function wont run, but i noticed it does run when the characterRemoving function is removed.
Any Ideas?
local DTS = game:GetService("DataStoreService")
local store = DTS:GetDataStore("ShirtColor")
game.Players.PlayerRemoving:Connect(function (plr)
plr.CharacterRemoving:Connect(function (char)
local success, errormessage = pcall(function ()
store:SetAsync(plr.UserId, char:FindFirstChild("BodyColors").TorsoColor3)
end)
if success then
print("GREEAT")
else
warn(errormessage)
end
end)
end)
game.Players.PlayerAdded:Connect(function (plr)
plr.CharacterAdded:Connect(function (char)
local NewBC = game.ReplicatedStorage.New:Clone()
local head = char:WaitForChild("Head")
local decal = head.face
local BodyColors = char:WaitForChild("Body Colors")
NewBC.Name = "BodyColors"
local color
local success, playerData = pcall(function ()
return store:GetAsync(plr.UserId)
end)
if playerData then
color = playerData
print(color)
else
color = Color3.fromRGB(math.random(0,256),math.random(0,256),math.random(0,256))
end
NewBC.TorsoColor3 = color
print(decal)
task.wait(0.3)
BodyColors:Destroy()
NewBC.Parent = char
decal.Texture = "rbxasset://textures/face.png"
print(decal.Texture)
for i, part in pairs(char:GetDescendants()) do
if part:isA("Accessory") then
part:Destroy()
end
if part:isA("Pants") or part:isA("Shirt") then
part:Destroy()
end
end
if BodyColors then
BodyColors:Destroy()
end
local shirt = Instance.new("ShirtGraphic", char)
shirt.Graphic = "http://www.roblox.com/asset/?id=296347866"
end)
end)