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

[SOLVED]Help with Data Store getAsync

frame.Load.MouseButton1Down:connect(function()
	if ds:getAsync(player.Name.."Race") and ds:getAsync(player.Name.."Race") ~= "" or ds:getAsync(player.Name.."Race") ~= 0 then
	frame.New.Active = false
	frame.Load.Active = false
	local stats=Instance.new("Model")
	local beli = Instance.new("NumberValue")
	beli.Parent = stats
	beli.Name = "Beli"
	local bounty = Instance.new("NumberValue")
	bounty.Parent = stats
	bounty.Name = "Bounty"
	local race = Instance.new("StringValue")
	race.Name = "Race"
	race.Parent = stats
	local weapon = Instance.new("NumberValue")
	weapon.Name = "WeaponLevel"
	weapon.Value=1
	weapon.Parent = stats
	local job=Instance.new("StringValue")
	job.Name="Faction"
	job.Parent=stats
	job.Value="Pirate"
	local df=Instance.new("StringValue")
	df.Name="DF"
	df.Value=""
	df.Parent=stats
	stats.Parent = player
	for i,v in pairs(stats:getChildren()) do
		v.Value=ds:getAsync(player.Name..v.Name)
	end
	player:LoadCharacter()
	else
		load.Text = "You have no data!"
		wait(2)
		load.Text = "Load"
	end
end)

When I click "Load" in the frame, it is supposed to get my stats from the Global Data Store but the output says on line 55(which in the sample is line 29), a string is expected. What does that mean?

1 answer

When there's nothing to load, datastore returns nothing (literally, nothing, not even nil). So if there's nothing to load, and your assigning v.Value to nil, it's not going to work, it expects a string.

To fix this is simple, just add or "" after your getAsync, but you might wanna change what's in the string to be a default..

1 comment

0

Thank you

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