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

Is it ok if this datastore script doesn't work in studio but does in the actual game?

Asked by 5 years ago

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..

local DS = game:GetService("DataStoreService")
local myDS = DS:GetDataStore("FlexingSimulatorDataStor")

local startingFlexCoins = 15

game.Players.PlayerAdded:Connect(function(plr)
    local leader = Instance.new("Folder",plr)
    leader.Name = "leaderstats"

    local stats = Instance.new("Configuration",plr)
    stats.Name = "Stats"

    local flexCoins = Instance.new("IntValue",leader)
    flexCoins.Name = "FlexCoins"

    local ego = Instance.new("IntValue",stats)
    ego.Name = "Ego"

    local key = "key - "..plr.UserId 

    local playerData = myDS:GetAsync(key)

    if playerData then
        flexCoins.Value = playerData[1] or startingFlexCoins
        ego.Value = playerData[2]
    else
        local valuesToSave = {flexCoins.Value,ego.Value}
        myDS:SetAsync(key,valuesToSave)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local key = "key - "..plr.UserId
    local data = {
        plr.leaderstats.FlexCoins.Value,
        plr.Stats.Ego.Value,
    }

    myDS:SetAsync(key,data)
end)

0
Yea, that's fine, because when you change the values on the explorer tab, you're changing them from the client, unless you switch your view to the server view while playing. ScrubSadmir 200 — 5y
0
I heard server stuff used to never work in the studio, so if you are running it as the client, it won't look like it's working. SteamG00B 1633 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

This is pretty normal, and sometimes it will randomly save (lol), if you need coins for testing then put in a script temporarily that searches for Player1 and give them coins

Ad

Answer this question