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

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

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)

2 comments

0

Specify what you mean by it stayed open are you saying when you joined the game the shop frame was visible?

0

Yeah

1 answer

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.

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