At line 06, you attempted to define cashdata again as the data in the data store, which in this case is a number. So when you attempted to set the data at line 52, you're actually calling SetAsync on a number. You need to use a different variable name for the variable to not override itself.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | local copieddata = script.Data:Clone() |
03 | copieddata.Parent = plr |
04 | local data = game:GetService( "DataStoreService" ) |
05 | local cashdata = data:GetDataStore( "Cash" ) |
06 | local success, cash = pcall ( function () |
07 | return cashdata:GetAsync(plr) |
12 | cashdata:SetAsync(plr, 0 ) |
14 | copieddata.Cash.Value = cash |
21 | local copiedplotinfo = script.PlotInformation:Clone() |
22 | copiedplotinfo.Parent = plr |
23 | if workspace.Plots.Plot 1. Owner.Value = = "Nil" then |
24 | copiedplotinfo.Plot.Value = "Plot1" |
25 | workspace.Plots.Plot 1. Owner.Value = plr.Name |
26 | elseif workspace.Plots.Plot 2. Owner.Value = = "Nil" then |
27 | copiedplotinfo.Plot.Value = "Plot2" |
28 | workspace.Plots.Plot 2. Owner.Value = plr.Name |
29 | elseif workspace.Plots.Plot 3. Owner.Value = = "Nil" then |
30 | copiedplotinfo.Plot.Value = "Plot3" |
31 | workspace.Plots.Plot 3. Owner.Value = plr.Name |
32 | elseif workspace.Plots.Plot 4. Owner.Value = = "Nil" then |
33 | copiedplotinfo.Plot.Value = "Plot4" |
34 | workspace.Plots.Plot 4. Owner.Value = plr.Name |
39 | local currentplot = copiedplotinfo.Plot.Value |
40 | local plot = workspace.Plots:FindFirstChild(currentplot) |
41 | local function farmincome() |
42 | local farm = plot.Farm |
43 | local farmlvl = farm.LVL.Value |
48 | local Cash = copieddata.Cash |
49 | Cash.Value = Cash.Value + income |
50 | print ( "Gave farm cash respectively. New cash=" .. Cash.Value) |
51 | print ( "Amount of cash recieved=" .. income) |
52 | cashdata:SetAsync(plr, Cash.Value) |
55 | local function westernshootoutscoutedition() |