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

How do I make the Buy text box say "Not Enough" for when buying an Item?

This might be a dumb question but how can I say the text 'Not Enough' When the player doesn't have enough levels and not enough cash?

local price = script.Parent.Parent.Price
local level = script.Parent.Parent.Level
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
	 
script.Parent.MouseButton1Click:Connect(function()
    if player.Character:FindFirstChild(tool.Value) or player.Backpack:FindFirstChild(tool.value) then 
	script.Parent.Text = 'Bought'
	wait(1)
	script.Parent.Text = 'Buy'
	return end --Returns if player is holding (or have on the backpack) the tool name (tool.Value)
    if player.leaderstats:FindFirstChild("Level").Value >= level.Value then
		if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then
	        player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value
	        game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
		end
    end
end)

4 comments

0

Try changing on line 13+14, .....("Level").Value >= .... Uhm, > is a symbol for below, but... below what? ( Below what level )

0

Idk if I could put a else since it it has to be equal to or greater than the require level, because if it's below the required level, it need for it to say "Not Enough" and for the cash too.

0

Is this a local script? Line 5 could be replaced to game.Players.LocalPlayer. Stay away from using so many parents.

0

Yes it's a local script

1 answer

✓ Accepted answer

****Make sure this is in a local script

And if it doesn't work let me know.

local price = script.Parent.Parent.Price
local level = script.Parent.Parent.Level
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    if player.leaderstats:FindFirstChild("Level").Value >= level.Value then
        if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then
            player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value
            game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
			script.Parent.Text = "BOUGHT"
			script.Parent.Active = false
			script.Parent.AutoButtonColor = false
			script.Parent.Selectable = false
        end
    end
	if player.leaderstats:FindFirstChild("Level").Value <= level.Value then
		if player.leaderstats:FindFirstChild("Cash").Value <= price.Value then
			local OlText = ""..script.Parent.Text
			wait(.6)
			script.Parent.Text = "NOT ENOUGH CASH"
			wait(2)
			script.Parent.Text = OlText
		end
	end
end)

4 comments

0

Thanks that actually worked

0

you can use else :/

0

I know, it was a long script I gave up after 5 seconds trying to find the right line.

0

Oof

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