For some reason i copied a whole tutorial i even enabled api services and it isnt even working i keep getting this stupid error: ServerScriptService.DATA.MainData:38: ServerScriptService.DATA.MainData:32: attempt to index nil with 'StandPower'

heres the serverscript

local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("Stand")
game.Players.PlayerAdded:Connect(function(player)
	local stander = Instance.new("Folder",player)
	stander.Name = "StandFolder"

	local standname = Instance.new("StringValue",stander)
	standname.Name = "standname"
	standname.Value = "None"
	
	local data
	local success, errormsg = pcall(function()
		data = datastore:GetAsync("Player_"..player.UserId)   
	end)
	
	if data ~= nil then
		standname.Value = data
	else
		warn(fail)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success, errormsg = pcall(function()
		datastore:SetAsync("Player_"..player.UserId,player.StandFolder.standname.Value)   
	end)
	if success then
		print'done'
	else
		print'fail'
		error(errormsg)
	end
end)

5 comments

0

SAME BRUH!!! i didnt get help tho

0

rip

0

If your just testing in studio I suggest testing it in the actual game itself, because I had a similar problem where there where no errors to the code but it worked in the actual game

0

Still doesnt work

0

Is that the whole script?