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

If player has bought go away?

Asked by 9 years ago

Hi I was trying to script this shop script and when they bought it the button went away. But if you died and still bought it the button would come back up. Can you help? This is my guess. Everything was working until I added the if then statment at the top. Please help!

price = 550
plr = game.Players.LocalPlayer
debounce = false
if plr.Backpack.ClassicSword.Configurations.LungeDamage == 50 and plr.Startergear.ClassicSword.Configurations.LungeDamage == 50 then

    script.Parent.MouseButton1Down:connect(function()
   if debounce then return end 
    local v = plr.leaderstats.Credits
    debounce = true 
    if v.Value >= price then
        plr.Backpack.ClassicSword.Configurations.LungeDamage.Value = 50 or  plr.Backpack.StarterGear.Configurations.LungeDamage.Value +50


        v.Value = v.Value - price
        script.Parent.Parent.Buy.Visible = true
        wait(0.2) 

        for i = 0.1,1,0.1 do
            wait(0.1)
            script.Parent.Parent.Buy.TextTransparency = i
        end

        script.Parent.Active = false
        script.Parent.Visible = false
        script.Parent.Parent.upgrade2.Visible = true
        script.Parent.Parent.Buy.Position = UDim2.new(0, 200, 0, 100)

        print('You bought the item!')


    else

    print ('Cant buy item!')
        script.Parent.Parent.Nope.Visible = true
script.Parent.Parent.Parent.Frame.Nope2.Text = "You need "..550 - plr.leaderstats.Credits.Value.." more Credits to buy this!"
            script.Parent.Parent.Nope.TextTransparency = 0
            script.Parent.Parent.Nope2.TextTransparency = 0
            wait(2)
                    for i = .1,1,.1 do 
wait(0.1)
            script.Parent.Parent.Nope.TextTransparency = i
            script.Parent.Parent.Nope2.TextTransparency = i         
        end
    end
debounce = false
    end)
else 
    script.Parent.Active = false
    script.Parent.Visible = false
end

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

You're indexing a game object and asking if it is equal to a number. It is not, because it is a object. It does have a Value property, however, which is what you mean to be looking at.

0
How would I approach it? docrobloxman52 407 — 9y
0
Add .Value after the two references to LungeDamage on line 4. Spongocardo 1991 — 9y
Ad

Answer this question