Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

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.

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.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.