Is it ok if this datastore script doesn't work in studio but does in the actual game?
I've enabled API access to roblox studio btw, I am very confused how this is not working on studio but works on the actual game, might be cause I am changing the values through the explorer and properties tab and not through like some sort of script when I am in studio and when I am in the actual game I pull out the dev console and type command to give myself money that way..
01 | local DS = game:GetService( "DataStoreService" ) |
02 | local myDS = DS:GetDataStore( "FlexingSimulatorDataStor" ) |
04 | local startingFlexCoins = 15 |
06 | game.Players.PlayerAdded:Connect( function (plr) |
07 | local leader = Instance.new( "Folder" ,plr) |
08 | leader.Name = "leaderstats" |
10 | local stats = Instance.new( "Configuration" ,plr) |
13 | local flexCoins = Instance.new( "IntValue" ,leader) |
14 | flexCoins.Name = "FlexCoins" |
16 | local ego = Instance.new( "IntValue" ,stats) |
19 | local key = "key - " ..plr.UserId |
21 | local playerData = myDS:GetAsync(key) |
24 | flexCoins.Value = playerData [ 1 ] or startingFlexCoins |
25 | ego.Value = playerData [ 2 ] |
27 | local valuesToSave = { flexCoins.Value,ego.Value } |
28 | myDS:SetAsync(key,valuesToSave) |
32 | game.Players.PlayerRemoving:Connect( function (plr) |
33 | local key = "key - " ..plr.UserId |
35 | plr.leaderstats.FlexCoins.Value, |
39 | myDS:SetAsync(key,data) |