You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i want to make a value that saves to a player.
What is the issue? Include screenshots / videos if possible!
i am new to datastoreservice and i am trying it to work now for over 6 hours. i watched alvinblox, devkings and avishals tuturiols about it but i just can figure it out, i also enabled studio API acces
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i searched in other posts on the devforum but i didn’t understand the answers or there wasn’t even a solution, i searched the developer hub but they don’t give that much info and as already said, i watched 3 different tuturials.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
it also doens’t give an error and it only prints “pcall 2 has started”. after that it doesn’t print anything
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local datastoreservice = game:GetService(“DataStoreService”)
local mydata = datastoreservice:GetDataStore(“mydata”)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "cash"
cash.Parent = leaderstats
local data
local success, erromessage = pcall(function()
data = mydata:GetAsync(player.UserId,"-cash")
end)
if success then
cash.Value = data
end
local good, bad = pcall(function()
print("pcall 2 has started")
mydata:SetAsync(player.UserId.."-cash", player.leaderstats.cash.Value)
print("pcall 2 is going to end")
end)
print("pcall 2 has ended")
if good then
print("pcall 2 was good")
else
print("pcall 2 gave an error")
end