So yeah the title sums it up
It says “All good” then prints the data then does nothing after that
Scripts (very messy)
Server script
--Variables
remote = game.ReplicatedStorage.SaveAvatar
dss = game:GetService("DataStoreService")
avatarStore = dss:GetDataStore("avatarStore")
ts = game:GetService("TeleportService")
players = game:GetService("Players")
debounce = true
--Functions
task.wait(3)
debounce = false
function isDataThenTele(player)
local success,errorMessage = pcall(function()
local data1 = avatarStore:GetAsync("Shirt_"..player.UserId)
local data2 = avatarStore:GetAsync("Pants_"..player.UserId)
local data3 = avatarStore:GetAsync("Face_"..player.UserId)
local data4 = avatarStore:GetAsync("Color_"..player.UserId)
if (data1 and data2) and (data3 and data4) then
print("All good!")
print(data1)
print(data2)
print(data3)
print(data4)
return true
else
print("One of these is missing..")
print(data1 ~= nil)
print(data2 ~= nil)
print(data3 ~= nil)
print(data4 ~= nil)
return false
end
end)
if not success then
warn(errorMessage)
player:Kick("There was an error fetching data.. :(")
end
end
function TeleportAndSave(player,Clothes)
local button = player.PlayerGui.CharacterCustomization.Frame.Confirm
local shirtkey = "Shirt_"..player.UserId
local pantskey = "Pants_"..player.UserId
local facekey = "Face_"..player.UserId
local colorkey = "Color_"..player.UserId
if debounce == false then
button.Text = ("Loading..")
debounce = true
local success, errorMessage = pcall(function()
avatarStore:SetAsync(shirtkey,Clothes[1])
avatarStore:SetAsync(pantskey,Clothes[2])
avatarStore:SetAsync(colorkey,Clothes[3])
avatarStore:SetAsync(facekey,Clothes[4])
debounce = false
task.wait(2)
button.Text = "Teleporting.. :)"
local hasData = isDataThenTele(player)
if hasData then
print("Has data, next stage")
local success, errorMessage = pcall(function()
local TeleOptions = Instance.new("TeleportOptions")
local TeleOptionsSet = {
data1 = avatarStore:GetAsync("Shirt_"..player.UserId),
data2 = avatarStore:GetAsync("Pants_"..player.UserId),
data3 = avatarStore:GetAsync("Face_"..player.UserId),
data4 = avatarStore:GetAsync("Color_"..player.UserId)
}
print(TeleOptions)
TeleOptions:SetTeleportData(TeleOptionsSet)
if not game:GetService("RunService"):IsStudio() then
ts:TeleportAsync(7279402264,{player},TeleOptions)
else
print("In studio..")
end
end)
if not success then
print(errorMessage)
player:Kick("Sorry, teleport failed :( "..errorMessage)
end
elseif hasData == false then
print("No data...")
end
end)
if not success then
print(errorMessage)
button.Text = ("Sorry, an error occured, try again. :(")
debounce = false
end
elseif debounce == true then
warn("Debounce!")
end
end
players.PlayerAdded:Connect(function(plr)
print(plr)
if isDataThenTele(plr) then
local success, errorMessage = pcall(function()
local TeleOptions = Instance.new("TeleportOptions")
local TeleOptionsSet = {
data1 = avatarStore:GetAsync("Shirt_"..plr.UserId),
data2 = avatarStore:GetAsync("Pants_"..plr.UserId),
data3 = avatarStore:GetAsync("Face_"..plr.UserId),
data4 = avatarStore:GetAsync("Color_"..plr.UserId)
}
print(TeleOptions)
TeleOptions:SetTeleportData(TeleOptionsSet)
if not game:GetService("RunService"):IsStudio() then
ts:TeleportAsync(7279402264,{plr},TeleOptions)
else
print("In studio..")
end
end)
if not success then
print(errorMessage)
plr:Kick("Sorry, teleport failed :( "..errorMessage)
end
else
TeleportAndSave()
end
end)
remote.OnServerEvent:Connect(TeleportAndSave)
Local script
button = script.Parent
sound = button.Ding
saveavatar = game.ReplicatedStorage.SaveAvatar
Character = workspace.CustomizableCharacter
task.wait(1)
button.Activated:Connect(function()
sound.Playing = true
local Clothes = {
Character:FindFirstChildWhichIsA("Shirt").ShirtTemplate,
Character:FindFirstChildWhichIsA("Pants").PantsTemplate,
tostring(Character.BodyColors.HeadColor),
tostring(Character.Head.Face.Texture)
}
saveavatar:FireServer(Clothes)
end)