DataStore Problem (SetAsync)

Hello. I’ve been trying to create a script where if you have a certain gamepass, you can run a /tag command in chat and change/add a tag next to your username which saves using DataStore. The problem is SetAsync(). It doesn’t work. GetAsync works perfectly fine but this one doesn’t. Also, this is a server script located in ServerScriptService. I am a fairly new scripter and I would love some help. Thanks!

> local dbs = game:GetService('DataStoreService')
> local mps = game:GetService('MarketplaceService')
> 
> local chs = require(game.ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
> 
> local data
> 
> game.Players.PlayerAdded:Connect(function(plr)
> 	plr.Chatted:Connect(function(msg)
> 		if mps:UserOwnsGamePassAsync(plr.UserId, also classified) then
> 		    if string.sub(msg, 1, 4) == '/tag' then
> 				local s1,s2 = pcall(function()
> 					dbs:GetDataStore('classified'):SetAsync(plr.UserId, tostring(string.sub(msg, 6)))
> 				end)
> 			end
> 		end
> 	end)
> end)
> 
> chs.SpeakerAdded:Connect(function(plrName)
> 	local speaker = chs:GetSpeaker(plrName)
> 	local plr = game.Players:WaitForChild(plrName)
> 	
> 	data = dbs:GetDataStore('classified'):GetAsync(plr.UserId)
> 	
> 	if mps:UserOwnsGamePassAsync(plr.UserId, also classified) then
> 		speaker:SetExtraData('Tags', {{TagText = data, TagColor = Color3.fromRGB(0,0,0)}})
> 	end
> end)
1 Like

Make sure it’s not nil. do print(data)

The data local is only used for GetAsync, and GetAsync already works.

Are you use setasync locally or on the server?