hello
-
What do you want to achieve? I want to have this save script save your head size through the leaderstats script
-
What is the issue? I cannot save the leaderstats nor the head size
-
What solutions have you tried so far? I looked at tutorials, the devforum, and the toolbox
-
Ask me anything, I can try to answer
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("playerData")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
--making leaderstats
task.spawn(function()
while task.wait() do
HeadSize.Value = Character.Head.Size.Magnitude
end
end)
local data
local success, errormessage = pcall(function()
data = playerData:GetAsync(Player.UserId.."-HeadSize")
end)
if success then
HeadSize.Value = data
else
print("Error while getting your data")
warn(errormessage)
end
end)
end)
Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
playerData:SetAsync(player.UserId.."-HeadSize", player.leaderstats.Value.Value)
end)
if success then
print("Data successfully saved!")
else
print("There was an error while saving the data")
warn(errormessage)
end
end)
thankth alot for reading