If no data in the database

  1. What do you want to achieve?
    Advanced ATM machines can use someone else’s credit card

  2. What is the issue?
    I have searched many articles but not about this

  3. What solutions have you tried so far?
    nothing now… ah

in sciprt’s line 15 what should be filled in if there is no data in the database
scirpt

local replicatedstorage = game:GetService("ReplicatedStorage")
local ccnnb = replicatedstorage:FindFirstChild("CCnb")
local datastoreservervice = game:GetService("DataStoreService")
local CC = datastoreservervice:GetDataStore("CC")
local Tool = game.Players.LocalPlayer.Backpack["credit card"].Value.Value

ccnnb.OnServerEvent:Connect(function(player)
	local playerUserId = player.UserId
	
	local CCnbget
	local success, errormessage = pcall(function()
		CCnbget = CC:GetAsync(playerUserId)
	end)
	
	if CCnbget =       then
		Tool = playerUserId
	end
end)

If the datastore errors, success returns false. If the datastore successfully retrieves data, it returns the data, or if there are none, it returns nil.

In your case, if there is no data yet, it should return nil

1 Like