Hi, I'm trying to save a value to my datastore, When I run the script it says nothing. Help?
Script is in serverscriptservice and FE is on.
Pic of output:
if you want to, just give me a working script with my variables instead of attempting to fix this one
local players = game:GetService("Players")
local Workpace = game:GetService("Workspace")
local DataStoreService = game:GetService("DataStoreService")
local StrengthData = DataStoreService:GetDataStore("StrengthData")
players.PlayerAdded:Connect(function(plr)
wait(3)
local strength = plr.PlayerGui.Points:WaitForChild("PointDisplay")
local data
local success, errormessage = pcall(function()
StrengthData:GetAsync(plr.UserId.."-Strength")
end)
if success then
strength.StrengthValue.Value = data
else
warn(errormessage)
print("couldnt get the data")
end
end)
players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
StrengthData:SetAsync(plr.UserId.."-Strength", plr.PlayerGui.Points.PointDisplay.StrengthValue.Value)
end)
if success then
print("Strength Saved")
else
print("Error when saving data")
warn(errormessage)
end
end)

3 comments
It could be possible that the PlayerAdded script is being ran after the player is added, therefore not running.
its wrapped in a p-call tho
also, i wouldnt be able to access the gui without the wait