When i press E it wont let me open the gui - script issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To fix my issue of script with gui

  2. What is the issue? Include screenshots / videos if possible!
    My issue is that when i copy and paste my game script
    into another game studio file
    it wont let me press E to open GUI
    Its like doesnt work
    In the console it doesnt say anything about this error

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Trying to remake a new script of open/close
    Nothing work

local plr = game.Players.LocalPlayer
local ui = plr.PlayerGui:WaitForChild("TheShop",100)
local npc = game.Workspace:WaitForChild("Rig",100)
local items = ui.Main.ScrollingFrame
local template = ui.Template.TextButton
local remote = game.ReplicatedStorage.ShopEvent
local maingroup = 10747388
local selected = nil

function create_list()
	for i,v in pairs(game.ReplicatedStorage.Shop:GetChildren()) do
		if not items:FindFirstChild(v.Name) then
			local newbutton = template:Clone()
			newbutton.Name = v.Name
			newbutton.Text = v.Name
			newbutton.Parent = items
			newbutton.Visible = true
		end
	end
end

function get_price(item)
	if game.ReplicatedStorage.Shop:FindFirstChild(item) then
		local found = game.ReplicatedStorage.Shop:FindFirstChild(item)
		return found.Price.Value
	else
		items:FindFirstChild(item).Text = "No Pricing found for "..item
		task.wait(2)
		items:FindFirstChild(item).Text = item
	end
end

task.wait(0.2)

create_list()

for i,v in pairs(items:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Down:Connect(function()
			selected = v.Name
			spawn(function()
				v.TextColor3 = Color3.fromRGB(85, 255, 0)
				task.wait(1)
				v.TextColor3 = Color3.fromRGB(255, 255, 255)
			end)
			if plr:IsInGroup(maingroup) then
				ui.Main.Price.Text = '<b>'.."Price: "..'</b>'..get_price(v.Name) - 200
				ui.Main.Discount.Text = '<b>'.."Discount (Membership): "..'</b>'..'<font color="rgb(138, 255, 109)">'.."Yes"..'</font>'
			else
				ui.Main.Price.Text = '<b>'.."Price: "..'</b>'..get_price(v.Name)
				ui.Main.Discount.Text = '<b>'.."Discount (Membership): "..'</b>'..'<font color="rgb(255,71,71)">'.."No"..'</font>'
			end
			ui.Main.Selection.Text = '<b>'.."Selected: "..'</b>'..v.Name
		end)
	end
end

ui.Main.Purchase.MouseButton1Down:Connect(function()
	if selected ~= nil then
		remote:FireServer(selected)
		task.wait(0.2)
		ui.Main.Selection.Text = '<b>'.."Selected: "..'</b>'
		ui.Main.Price.Text = '<b>'.."Price: "..'</b>'
		ui.Main.Discount.Text = '<b>'.."Discount (Membership): "..'</b>'
		selected = nil
	else
		messanger("Error", "Select the item from the list once again! And press Purchase!")
	end
end)

function messanger(mode,text)
	if mode == "Error" then
		ui.Main.Visible = false
		ui.NotifBox.Visible = true
		ui.NotifBox.TextLabel.Text = '<font color="rgb(255,71,71)">'.."ERROR: "..'</font>'..text
		task.wait(4)
		ui.NotifBox.TextLabel.Text = ""
		ui.NotifBox.Visible = false
		ui.Main.Visible = true
	end
end

npc.Head.ProximityPrompt.Triggered:Connect(function()
	if not ui.Main.Visible then
		ui.Main.Visible = true
	end
end)

ui.Main.Close.MouseButton1Down:Connect(function()
	if ui.Main.Visible then
		ui.Main.Visible = false
	end
end)

remote.OnClientEvent:Connect(function(mode,text)
	messanger(mode,text)
end)

With pressing E, do you mean the ProximityPrompt?

Try removing the check for if the UI is not visible. It seems not to matter since you aren’t doing path.Visible = not path.Visible.

If that fixes it, something is up with your UI’s visibility.

Edit: Do the same with the close button, if your UI isn’t visible then you can’t click it.

Also, why are you using a WaitForChild maximum yield time of 100 seconds? I don’t see why you wouldn’t just remove that since 100 seconds is quite a while.

Yea im using proximityprompt for it
but when i try keeping press E it wont let me open the gui

which line should i add that help me please

Here in your code. Remove the checks for the UI visibility.

You want me to remove the

ui.main.visible = true??

No, I want you to remove the checks before setting the UI’s visibility.

You are checking if the UI is not visible before setting the visibility to true, and the reverse of that for the close button.

Since you are setting it to a fixed Boolean these checks aren’t really required.

Im sorry im still very confuse of which line u want me to add it

Remove the two lines I just quoted and see if that fixes it.

image
here some error line

No, remove the things which you just added, as well as the end next to it without the ) symbol behind it. (Do this with both connections)

You want me to add the line u give me

into the inside of ()??

Replace this with

npc.Head.ProximityPrompt.Triggered:Connect(function()
	ui.Main.Visible = true
end)

ui.Main.Close.MouseButton1Down:Connect(function()
	ui.Main.Visible = false
end)

Nope it still same issue it wont let me open the gui

Is the ScreenGui Instance you’re using enabled

The instance I’m talking about is the one stated as the ui variable

So what do u want me to do with the screengui and the frame?

is the screengui instance enabled or not

yes but the frame main is unvisible