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

Why won't my shop gui button and text work?

Asked by 6 years ago

I have a GUI shop that has buttons. The button's are to buy weapons, when you own you buy the weapon and then click it again, it's supposed to displays a text label saying that it is "Equipped".

I made a script for the store buttons each so that it can show only one weapon already equipped, meaning once one button is clicked, the text label of the button you clicked says "equipped", and the other "equipped" text labels of different buttons becomes invisible.

The problem is that the equipped text labels aren't disappearing and sometimes after clicking the buttons. It is also working in studio, but not working in game.

What did I do wrong? Can you help me? Thank you!

This is the equipped text label's script:

local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local points = player:WaitForChild("leaderstats")["Player Points"]
local value = 2500 -- edit here
local name = "DarkHeartSword" -- here
local altname = "Darkheart"
local swords = script.Parent.Parent:GetChildren()
local Currently_Equipped = false
function TweenReceipt()
    local debounce = false

    if debounce == false then
        debounce = true
    script.Parent.Parent.Parent.MoneyNeeded.Visible = true
    script.Parent.Parent.Parent.MoneyNeeded.Amount.Text = value - points.Value
    script.Parent.Parent.Parent.MoneyNeeded:TweenPosition(UDim2.new(0, 300, 0, -100),"Out", "Quart", 1.5)
    wait(2.5)
    script.Parent.Parent.Parent.MoneyNeeded:TweenPosition(UDim2.new(0, 1300, 0, -100), "Out", "Quart", 0.2)
    script.Parent.Parent.Parent.MoneyNeeded.Position = UDim2.new(0, -1000, 0, -100)
    script.Parent.Parent.Parent.MoneyNeeded.Visible = false

    end
    debounce = false
end
script.Parent.MouseButton1Click:connect(function()
    if not player.Swords:FindFirstChild(altname) then -- edit here

        if points.Value >= value then -- buying clause
        points.Value = points.Value - value
        local Sword = Instance.new("BoolValue", player.Swords)
        Sword.Name = altname -- here
        script.Parent.Owned.Visible = true
        else
            TweenReceipt()
        end
    elseif Currently_Equipped == false then
        for i, v in pairs(swords) do

        v.Equipped.Visible = false


        script.Parent.Equipped.Visible = true
        --player.Swords.Darkheart.Value = true -- edit here
        --player.PersonalSword.Value = altname

        end
        Currently_Equipped = true

    elseif Currently_Equipped == true then 
    for i, v in pairs(swords) do

        v.Equipped.Visible = false
        script.Parent.Equipped.Visible = true

    end
    end
    Currently_Equipped = false

end)
if player:WaitForChild("Swords"):FindFirstChild(altname) then -- final edit
    script.Parent.Owned.Visible = true
end

Answer this question