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

[SOLVED] How do i make it so i can buy something but i have more than the initial price?

Im making this game where theres a shop to buy stuff like a dance potion but it only does the exact number, not higher amounts. What im trying to do is if you have more SP than the buying amount you can still buy it. The price for debugging right now is 1, but i plan to make it 10 when i've fixed it. I've tried many different solutions but its not working. Heres the code. You earn the SP every 30 seconds

function pickup(Player)
	if Player.leaderstats.SP.Value == 1 then --What im trying to do is if there is enough SP you can get the item
    if not Player.Backpack:FindFirstChild("DancePotion") then-- The rest is just moving the item into your inventory which does work
        local Tool = game.ServerStorage.DancePotion:Clone()
        Tool.Parent = Player.Backpack
    end
end
end
script.Parent.ClickDetector.MouseClick:connect(pickup)

Heres the leaderboard script im using:

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	
	local SP = Instance.new("IntValue",leaderstats)
	SP.Name = "SP"
	SP.Value = 0
	
	while true do
		wait(30)
		SP.Value = SP.Value + 1
		print(player.Name .. "'s SP value is now " .. SP.Value)-- This is for debugging purposes
	end
end)

1 answer

✓ Accepted answer

What you're looking for is not "==" it is ">=" which means greater than or equal to. "==" will only look for a direct certain value

1 comment

0

Thanks for the help!

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