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

Im trying to make a shop script but i get an error i dont understand,What's wrong with the code?

I'm trying to make a shop script where when you touch an object a gui pops up, And then you can select what you wish to purchase. I've managed to make it so that when you touch an object the gui pops up but i can't seem to make you able to purchase anything.

Script:

Money = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Value
function Purchase()
	if Money == Money >100 then
		Money = Money - 100
		game.ReplicatedStorage.NyanCandy.Parent = script.Parent.Parent.Parent.Parent.Parent.Backpack
	else
		print("Error")
	end
end

script.Parent.MouseButton1Click:connect(Purchase)

Error: "Players.bestrindberg.PlayerGui.Shop.ScrollingFrame.1.Script:3: attempt to compare number with boolean"

help me please.....

1 comment

0

You cannot compare number with boolean values.

1 answer

This line of code is comparing the quantity of Money to the boolean (true/false) value that results from your next comparison.

if Money == Money >100 then

This is read as:

-- if (Money is equal to (is Money greater than 100?)) then do
if (Money == (Money > 100))then
	-- do stuff
end

Try:

if(Money > 100)then
	-- do stuff
end

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