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

If player has bought go away?

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

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.

2 comments

0

How would I approach it?

0

Add .Value after the two references to LungeDamage on line 4.

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