I was trying to make a data script following an alvin blox tutorial, I encountered some problems so I changed it according to some things I saw in the forums but it still doesn’t save, it has access to API services. Thanks in advance
My Terrible Script:
local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("myDataStore")
game:WaitForChild("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local JumpPower = Instance.new("IntValue")
JumpPower.Parent = leaderstats
JumpPower.Name = "JumpPower"
JumpPower.Value = 0
local data
local success, errormessage = pcall(function()
data = MyDataStore:GetAsync(player.UserId.."-JumpPower")
end)
if success then
JumpPower.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
MyDataStore:SetAsync(plr.UserId, plr.leaderstats.JumpPower.Value)
end)
if success then
print("Data Sucessfully Saved")
else
print("There was an error")
warn(errormessage)
end
end)