Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with adding a number value and number value from data store?

Asked by 8 years ago

http://prntscr.com/dh98vx


local DSService = game:GetService("DataStoreService") local PlayerDataStorage = DSService:GetDataStore("usjiiid9177nxx2") script.Parent.Add.MouseButton1Click:connect(function() local PlayerName = script.Parent.Parent.DataView.PlayerName.Text local PlayerDataSave = PlayerName.."usjiiid9177nxx2PS" local PlayerEXP = PlayerDataStorage:GetAsync(PlayerDataSave.."EXP") local Math1 = script.Parent.EXP.Text local Math2 = PlayerEXP local Answer = Math1 + Math2 PlayerDataStorage:SetAsync(PlayerDataSave.."EXP", Answer) print("Data changed.") end)

(Not the entire script, but everything else is irrelevant)


-- Enable Check local DSService = game:GetService("DataStoreService") local PlayerDataStorage = DSService:GetDataStore("usjiiid9177nxx2") local StartAdminComment = "No comment." local StartEXP = 0 game.Players.PlayerAdded:connect(function(Player) local PlayerDataSave = Player.Name.."usjiiid9177nxx2PS" Player:WaitForDataReady() local EXP = PlayerDataStorage:GetAsync(PlayerDataSave.."EXP") local RankInAI = Player:GetRoleInGroup(2842013) if EXP then stuff here else print(Player.Name.." does not have saved data. Saving data...") PlayerDataStorage:SetAsync(PlayerDataSave.."EXP", StartEXP) print("Data Saved") end end)

I'm basically trying to + the saved value with the value the officer tries to add to the player, but I get "Player.BionicWind.PlayerGui.Database.Maing.Officer.EXP:12: attempt to perform arithmetic on local 'Math2' (a nil value)"

In the script I save it, I've tried to save it as 0. And in the script that +'s it togheter, I've tried to do it directly and without any variables being Math1 and Math2

Should I save it as 1? Or what?

0
I'm not sure if it will help but put local Math1 = tonumber(script.Parent.EXP.Text) LittleBigDeveloper 245 — 8y
0
Doesen't seem to work, simplified version of what I want: First time a member joins, it creates a saved number value being 0, admins can change that number value, so it loads the saved number value, takes the new one from a textbox the admin typed in, plus them togheter, and save the new value. Could you maybe make a script it does exactly that? Then if it works, I'll try thinking of something els BionicWind 5 — 8y

Answer this question