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

Why does my shop gui suddenly stay open for no reason?

Asked by 3 years ago

I was trying to program walls that would close a shop gui if the player went through it. This is so I could prevent players from buying items for anywhere, while working on it for a while my shop guis suddenly stay open for no reason and no errors. I have no idea why either because I even undid some of the stuff I did and it stayed open. This was done in Team Create if that will answer anything.

local WeaponShopModel = workspace.Lobby["Weapon Shop"]
local WeaponShop = game.StarterGui.WeaponShop
local player = game.Players.LocalPlayer

WeaponShop.Frame.Visible = false

local function OpenWeaponShop()
    WeaponShop.Frame.Visible = true
end

local function CloseWeaponShop()
    WeaponShop.Frame.Visible = false
end

player.Character:WaitForChild("Humanoid")

WeaponShopModel.ShopExit1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and WeaponShop.Frame.Visible == true then
        CloseWeaponShop()
    end
end)

WeaponShopModel.ShopExit2.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and WeaponShop.Frame.Visible == true then
        CloseWeaponShop()
    end
end)


WeaponShopModel.Crypto.Torso.ProximityPrompt.Triggered:Connect(OpenWeaponShop)

WeaponShop.Frame.Exit.MouseButton1Click:Connect(CloseWeaponShop)
0
Specify what you mean by it stayed open are you saying when you joined the game the shop frame was visible? Jo1nts 134 — 3y
0
Yeah DocGooseYT 110 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I figured it out, it's because I'm editing the StarterGUI and not the player's gui. I fixed it by just changing the weaponshop variable to script.parent.WeaponShop instead of game.StarterGui.WeaponShop.

Ad

Answer this question