Hi! This message appeared in the output, I would like to know what I am doing wrong, could someone give me a hand?
Server script:
local DS = game:GetService("DataStoreService")
local Datastore = DS:GetDataStore("MyDatastore")
game.Players.PlayerAdded:Connect(function(player)
local Char = player.Character or player.CharacterAdded:Wait()
local BillboardGUI = Instance.new('BillboardGui')
BillboardGUI.Name = 'Billboard'
BillboardGUI.Size = UDim2.new(3, 0, 1, 0)
BillboardGUI.StudsOffset = Vector3.new(0, 2, 0) -- change the number 2 to make it go higher or lower
BillboardGUI.Parent = Char.Head
local TextLabel = Instance.new("TextLabel")
TextLabel.Size = UDim2.new(1,0,1,0)
TextLabel.Name = "TextLabel"
TextLabel.TextScaled = true
TextLabel.Parent = BillboardGUI
print("BillboardGUI Given to "..player.Name)
-- BillboardData
local Data
local success, errormessage = pcall(function()
Data = Datastore:GetAsync(player.UserId)
end)
if success then
print("Loaded "..player.Name)
if Data ~= nil then
print(player.Name.." has saved data")
TextLabel.Text = Data.Billboardtext
else -- If the Player is new
print(player.Name.." doesn't have saved data")
TextLabel.Text = "NEW PLAYER"
TextLabel.TextColor3 = Color3.fromRGB(255, 238, 245)
TextLabel.TextStrokeTransparency = 1 -- can be change (el contorno)
TextLabel.BackgroundTransparency = 1
end
else
warn(errormessage)
print("In the data is something wrong.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Data = {
BillboardText = player.Character.Billboard.TextLabel.Text
}
local success, errormessage = pcall(function()
Datastore:SetAsync(player.UserId, Data)
end)
if success then
print("Saved "..player.Name)
else
print("Error saving "..player.Name)
end
end)