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

Why is this appearing? "W002: Global 'stats' is deprecated"

I recieved help, to make the amount equal to what the player has, but for some reason, the word stats is underlined blue, and this pops up, "W002: Global 'stats' is deprecated". Could anyone help, I don't know what I should do. Thanks!

---------
amt=stats:FindFirstChild("Stored").Value
---------

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if (choice == script.Parent.Choice1) then
		if (player ~= nil) then
			local stats = player:findFirstChild("leaderstats")
			local otherStats = player:findFirstChild("Stats2")
			if (stats ~= nil and otherStats ~= nil) then
				local playerStored = otherStats:findFirstChild("Stored")
				if stats:findFirstChild("Money").Value >= amt then
					otherStats:findFirstChild("Stored").Value = otherStats:findFirstChild("Stored").Value + amt
					stats:findFirstChild("Money").Value = stats:findFirstChild("Money").Value - amt
				end
			end
		end
	end

	if (choice == script.Parent.Choice2) then
		if (player ~= nil) then
			local stats = player:findFirstChild("leaderstats")
			local otherStats = player:findFirstChild("Stats2")
			if (stats ~= nil and otherStats ~= nil) then
				local playerStored = otherStats:findFirstChild("Stored")
				if otherStats:findFirstChild("Stored").Value >= amt then
					stats:findFirstChild("Money").Value = stats:findFirstChild("Money").Value + amt
					otherStats:findFirstChild("Stored").Value = otherStats:findFirstChild("Stored").Value - amt				
				end
			end
		end
	end
end)

1 answer

You never defined stats so Roblox thinks you're referring to this deprecated global that also happens to be called stats.

2 comments

1

Ok, so what do I do? Local stats = player:findFirstChild("leaderstats")

0

Yes.

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