Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

0
Thanks for the help! MagneticISO 2 — 5y
Ad

Answer this question