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

Data saving script not saving data and gives error?

The title says it all,

local Data = game:GetService('DataStoreService'):GetDataStore('SaveDem')
	 
	local prefix = 'user_'
	 
	 
	game.Players.PlayerAdded:Connect(function(player)
	    local folder = Instance.new('Folder')
	    folder.Name = 'leaderstats'	 
	    local RAP = Instance.new("IntValue", folder)
	    RAP.Name = "RAP"

	
	   local CrateBux =  Instance.new("IntValue", folder)
	   CrateBux.Name = "Crate Bux"

	
	   local IsCode1Used = Instance.new("BoolValue", folder)
	   IsCode1Used.Name = "IsCode1Used"

	   local IsCode2Used = Instance.new("BoolValue", folder)
	   IsCode2Used.Name = "IsCode2Used"
	 
	    local plrData = Data:GetAsync(prefix  .. tostring(player.UserId))
	 
	    if plrData then
	          RAP.Value = plrData[0] or 0
	          CrateBux.Value = plrData[1] or 0
	          IsCode1Used.Value = plrData[2] or false 
	          IsCode2Used.Value = plrData[3] or false
	           
	          
	   else
	 
	    Data:SetAsync(prefix  .. tostring(player.UserId), {
	        RAP.Value,
	        CrateBux.Value,
			IsCode1Used.Value,
			IsCode2Used.Value
	     })
	   end
	 
	end)
	 
	game.Players.PlayerRemoving:Connect(function(player)
	    Data:SetAsync(prefix  .. tostring(player.UserId), {
	        player.leaderstats['RAP'].Value,
	        player.leaderstats['Crate Bux'].Value,
			player.leaderstats['IsCode1Used'].Value,
			player.leaderstats['IsCode2Used'].Value
	    })
	end)

error: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden))

3 comments

1

This would happen if you are in team create and using the data store from another user.

0

So you mean the Owner has to write it? because we are in team create and I script for him

1

The data store would be owned by him so you would not have access to it. A group has shared access.

1 answer

Make sure that API services are enabled in the game's options. (go to roblox.com > create > your place > configure game > grant access to roblox API services)

1 comment

0

It is on and still gives me the error

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