I'm trying to make this script to add $100 every minute to the player's wallet. I also want to store and retrieve money for the player in a data storage. The problem is, is that studio is still giving me an error that says, "API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 You do not have permission to manage this place. You don't have edit permissions.))". Even though I get this error I have already allowed roblox studio access to API services. I am working on this project with my brother also using team create.

local playerService = game:GetService("Players")
local dataStore = game:GetService("DataStoreService"):GetDataStore("Currency")

local function StartMoneyCounter(player, value)
	local money = value
	spawn(function()
		while true do
			money = money + 100
			player.PlayerGui.MoneyScreenGui.MoneyLabel.Text = tostring(money)
			wait(60)
		end
	end)
end

playerService.PlayerAdded:connect(function(player)
	local uniqueKey = "id-"..player.userId
	local savedData = dataStore:GetAsync(uniqueKey)
	if savedData then
		StartMoneyCounter(player, savedData[1])
	else
		local saveNumber = {tonumber(player.PlayerGui.MoneyScreenGui.MoneyLabel.Text)}
		dataStore:SetAsync(uniqueKey, saveNumber)
		StartMoneyCounter(player, saveNumber[1])
	end
end)

playerService.PlayerRemoving:connect(function(player)
	local uniqueKey = "id-"..player.userId
	local saveTable = {tonumber(player.PlayerGui.MoneyScreenGui.MoneyLabel.Text)}
	dataStore:SetAsync(uniqueKey, saveTable)
end)

3 comments

0

The Owner only has the ability to use HttpService and DataStoreService in studio. If you want to also use it, you are going to have to play the game.

0

thanks I was able to get it working!

0

:connect() is deprecated now and only works in studio. Instead, use :Connect(). (I don't really like the update)