Hello developers/scripters hokyboy here with kinda a big issue, I made a data store and a script where u can buy stuff from a store the issue is when I buy stuff the data store does not register it because it does not print success and when u rejoin the game u don't have ur data
The datastore
local dsService = game:GetService("DataStoreService") local ds = dsService:GetDataStore("DataStored") local function statChange(playerId, views, subs, cash , diamonds,Pc,Montior) print("Stats Changed") local playerData = {views.Value, subs.Value, cash.Value, diamonds.Value, Pc.Value, Montior.Value} ds:SetAsync(playerId, playerData) end game.Players.PlayerAdded:Connect(function(plr) --NumberData-- local folder = Instance.new("Folder",plr) folder.Name = "leaderstats" local Subs = Instance.new("IntValue",folder) Subs.Name = "Subs" local Views = Instance.new("IntValue",folder) Views.Name = "Views" local Cash = Instance.new("IntValue",folder) Cash.Name = "Cash" local Diamonds = Instance.new("IntValue",folder) Diamonds.Name = "Diamonds" --Build Data-- local Pc = Instance.new("IntValue",folder) Pc.Name = "Pc" local Montior = Instance.new("IntValue",folder) Montior.Name = "Montior" local playerData = ds:GetAsync(plr.UserId) or nil print(playerData) local playerData = ds:GetAsync(plr.UserId) or nil print(playerData) if playerData then Views.Value = playerData[1] Subs.Value = playerData[2] Cash.Value = playerData[3] Diamonds.Value = playerData[4] Pc.Value = playerData[5] Montior.Value = playerData[6] end Subs.Changed:Connect(function() print("Works") statChange(plr.UserId, Views, Subs, Cash , Diamonds,Pc,Montior,Keyboard,Mouse) end) Views.Changed:Connect(function() statChange(plr.UserId, Views, Subs, Cash, Diamonds,Pc,Montior,Keyboard,Mouse) end) Cash.Changed:Connect(function() statChange(plr.UserId, Views, Subs, Cash, Diamonds,Pc,Montior,Keyboard,Mouse) end) Diamonds.Changed:Connect(function() statChange(plr.UserId, Views, Subs, Cash, Diamonds,Pc,Montior,Keyboard,Mouse) end) Pc.Changed:Connect(function() statChange(plr.UserId, Views, Subs, Cash, Diamonds,Pc,Montior,Keyboard,Mouse) end) Montior.Changed:Connect(function() statChange(plr.UserId, Views, Subs, Cash, Diamonds,Pc,Montior,Keyboard,Mouse) end) end) game:BindToClose(function() wait(5) end)
The local script in my GUI
local Pcframe = script.Parent.Shopframe1 Pcframe.buy.MouseButton1Click:Connect(function() if game.Players.LocalPlayer.leaderstats.Pc.Value == 0 then game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - 1000 game.Players.LocalPlayer.leaderstats.Pc.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 1 Pcframe.buy.Text = "Pc Maxed Out" Pcframe.buy.BackgroundColor3 = Color3.fromRGB(186, 0, 0) Pcframe.buy.Frame.BackgroundColor3 = Color3.fromRGB(147, 0, 0) end end)
I wish my data store registered it but I do not know how can someone please help me If u need more information to add me on discord
Externalsight#7068