Trying to save Value to DataStore, Please help?
Asked by
4 years ago Edited 4 years ago
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:
https://prnt.sc/ujsn6x
if you want to, just give me a working script with my variables instead of attempting to fix this one
01 | local players = game:GetService( "Players" ) |
03 | local Workpace = game:GetService( "Workspace" ) |
05 | local DataStoreService = game:GetService( "DataStoreService" ) |
07 | local StrengthData = DataStoreService:GetDataStore( "StrengthData" ) |
10 | players.PlayerAdded:Connect( function (plr) |
13 | local strength = plr.PlayerGui.Points:WaitForChild( "PointDisplay" ) |
17 | local success, errormessage = pcall ( function () |
18 | StrengthData:GetAsync(plr.UserId.. "-Strength" ) |
21 | strength.StrengthValue.Value = data |
24 | print ( "couldnt get the data" ) |
31 | players.PlayerRemoving:Connect( function (plr) |
34 | local success, errormessage = pcall ( function () |
36 | StrengthData:SetAsync(plr.UserId.. "-Strength" , plr.PlayerGui.Points.PointDisplay.StrengthValue.Value) |
44 | print ( "Strength Saved" ) |
47 | print ( "Error when saving data" ) |