Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My DataStore Dosent work but it says success pls help?

local DataStoreService = game:GetService("DataStoreService")
local MoneyDataStore = DataStoreService:GetDataStore("MoneyDataStore")
local player = game:GetService('Players')
local Money = 0
local debounce

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local MoneyCash = Instance.new("IntValue")
    MoneyCash.Name = "MoneyCash"
    MoneyCash.Value = 0``
    MoneyCash.Parent = leaderstats

    local success, errormessage = pcall(function()
        Money = MoneyDataStore:GetAsync(player.UserId.."-Cash")
        MoneyCash.Value = MoneyDataStore:GetAsync(player.UserId.."-Cash")
    end)

    if success then
        Money = MoneyCash.Value
    else
        print("Error something whent bad")
        warn('error with setting 1 '..errormessage)
        end
    game.Workspace.Touchedpart.Touched:Connect(function(p)
       if p.Parent:FindFirstChild("Humanoid") then
         if not debounce then
             debounce = true
             Money = Money + 1
             MoneyCash.Value = Money
             print(MoneyCash.Value)
             wait(0.4)
             debounce = false

         end
        end
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, errormassage = pcall(function()
        MoneyDataStore:GetAsync(player.UserId.."-Cash",player.leaderstats.MoneyCash.Value)
    end)

    if success then
        print(player.leaderstats.MoneyCash.Value)
        print("Data saved!")
    else
        print("there was an error when saving data")
        warn('error with saving 2 '..errormassage)
    end
end)

it says Data saved! on output but it doesent save any help

1 comment

0

BTW this is all of the code

1 answer

It will not work in studio unless you enable HTTP requests in studio. You can do this by opening up the game in studio, going to the home tab on the top bar, pressing game settings, going to "Options" and turning on "Allow HTTP requests"

This discussion is preserved as it was. New answers, comments, and votes are closed.