GUi not opening, interact E & scripting

Konichiwwa,
I’m trying to fix this issue with a script which is suppose to open a GUi and let player choose food which to cook and etc. Eventually it doesn’t work, I tried debugging code eventually didn’t work and still didn’t open. I’ve decided to take it up here if you guys can help or assist me.
I got many issues in console trying to fix did not really work. I mean not really errors ig?

code i used for debugging:

local proximity = --[[ Reference to your proximity prompt or trigger ]]
local CookingGui = --[[ Reference to your Cooking GUI ]]
local CookingMini = --[[ Reference to your Cooking Mini GUI ]]
local connections = {} – Table to store connections for each player
local playerLastInteraction = nil – Variable to track the last player interaction
– Function to get food items from replicated storage
local function GetFoodItems()
local foodItems = {} – Table to hold food items
– Assuming you have a folder named “FoodItems” in ReplicatedStorage
local foodFolder = game.ReplicatedStorage:FindFirstChild(“FoodItems”)

if foodFolder then
    for _, item in pairs(foodFolder:GetChildren()) do
        table.insert(foodItems, item.Name)  -- Collect item names or any other relevant data
    end
end

return foodItems

end

proximity.Triggered:Connect(function(player: Player)
warn(player.Name)

if not playerLastInteraction and player:IsInGroup(35411958) and player:GetRankInGroup(35411958) >= 3 then
    warn("Player is in the correct group and rank.")

    local playerGui = player:FindFirstChild("PlayerGui")
    playerLastInteraction = player

    -- Remove any previous GUIs that we don't want
    for _, item in pairs(playerGui:GetChildren()) do
        if item.Name == CookingGui.Name or item.Name == CookingMini.Name then
            item:Destroy()
        end
    end

    if connections[player] == nil then
        local clonedGui = CookingGui:Clone()
        clonedGui.Parent = playerGui
        clonedGui.Enabled = true

        -- Setup the GetDishes event
        local updateEvent = clonedGui:FindFirstChild("GetDishes")
        if updateEvent then
            local updateFoodConnection

            updateFoodConnection = updateEvent.OnServerEvent:Once(function(player)
                warn("Firing back to client response")
                local foodItems = GetFoodItems()
                updateEvent:FireClient(player, foodItems)
                warn(foodItems)

                updateFoodConnection:Disconnect()
                updateFoodConnection = nil
            end)
        else
            warn("GetDishes event not found in GUI.")
        end

        -- Setup the SelectDish event
        local selectEvent = clonedGui:FindFirstChild("SelectDish")
        if selectEvent then
            connections[player] = selectEvent.OnServerEvent:Once(selectCallback)
        else
            warn("SelectDish event not found in GUI.")
        end
    end
else
    warn("Player did not meet the criteria for opening the GUI.")
end end)

Do note this is just example I did setup everything which should be but still didn’t work!

1 Like

is the proximity prompt triggered function inside a local script? i believe they only work on server scripts.

Its inside a part named Grill and then ProximityPrompt like E interact. But hibachi script its in normal.

i dont really understand what you said… So when your doing this

Prompt.triggered:Connect(function()

what type of script is that on?

image
its like this.

1 Like

oh, then i have absolutely 0 idea why its not working :confused:

Yeah same… Even tho it worked before but when I copyied grill and etc to a new game it js doesn’t work anymore… I setted everything as usually (only shelves) and etc in right position

1 Like

@Gamemaster712Z I have recorded to show you console. Which doesn’t really display anything…

:link: Watch Untitled Game - Roblox Studio 2025-02-21 15-03-56 | Streamable

This is so weird… i see no errors and the script look perfectly fine.

Try printing something after you interact with the prompt mabye?

When I used debugging script it printed like attempting to create gui and etc. But no errors shown and it didnt create like clone or open gui or anything.

1 Like

Ok yeah then i have no idea at all… this is very weird

someone else might be able to see the issue but im blind or something lol

im sorry i could not help

I have to type for me to send this message

The point of the hibachi script is that it gets food from the FoodItems folder and it uses texture to create like a small pop out in the gui (frame) to choose which food to cook. But it wont open the gui or anything which should open main frame and do the rest.

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local CookingGui = ReplicatedStorage:FindFirstChild(“CookingGui”)
local CookingMini = ReplicatedStorage:FindFirstChild(“CookingMinigame”)
local TweenService = game:GetService(“TweenService”)
local Players = game:GetService(“Players”)

local hibachi = script.Parent
local grill = hibachi.Grill
local proximity = grill.ProximityPrompt

local teleportPart = hibachi.TeleportPart
local FirePart = hibachi.FirePart.Fire
local FireGoal = hibachi.EndGoal

local originalFirePartCFrame = FirePart.Parent.CFrame

local connections = {}

– store the last player object who interacted
local playerLastInteraction = nil
local lastShelfProximity = nil

– TODO: on player leave remove their connection

local RemoveClient = ReplicatedStorage:WaitForChild(“RemoveClient”)

local function cleanupConnections()
warn(connections)
for key, connection in pairs(connections) do
if typeof(connection) == “RBXScriptConnection” and connection.Connected then
connection:Disconnect()
–warn(“is .Connected?”, connection.Connected)
elseif typeof(connection) == “Instance” then
connection:Destroy()
end
connections[key] = nil
end
playerLastInteraction = nil
warn(connections)
end

local function reset_grill(player: Player)
local playerCharacter = player.Character or player.CharacterAdded:Wait()

playerCharacter.PrimaryPart.Anchored = false
FirePart.Enabled = false
playerLastInteraction = nil
–cookProximity:Destroy() removed by connection servicing
–shelfProximity.Enabled = false may be a future bug
proximity.Enabled = true

if lastShelfProximity ~= nil then
lastShelfProximity.Enabled = false
end

FirePart.Parent.CFrame = originalFirePartCFrame

playerLastInteraction = nil
–connections[player]:Disconnect()
–connections[player] = nil

local cleanup = {“clonedGotoBeam”, “attachment0”, “attachment1”}

for index, value in pairs(cleanup) do
if connections[value] ~= nil then
connections[value]:Destroy()
connections[value] = nil
end
end

end

RemoveClient.OnServerEvent:Connect(function(player: Player)
warn(“pressed exit button”)
local PlayerGui = player:WaitForChild(“PlayerGui”)
for _, gui in pairs(PlayerGui:GetChildren()) do
if gui.Name == “CookingGui” or “CookingMinigame” then
gui:Destroy()
end
end
cleanupConnections()
reset_grill(player)
end)

Players.PlayerAdded:Connect(function(player: Player)
player.CharacterRemoving:Connect(function(character)
warn(“cleanup character conncections”)
cleanupConnections()
reset_grill(player)
end)
end)

Players.PlayerRemoving:Connect(function(player: Player)

warn(player.Name, “Left the game and triggered a cleanup”)
cleanupConnections()
reset_grill(player)
end)

local function findClosestShelf(Hibachi:Model, Shelves:Model): Model
local closestShelf = nil
local closestDistance = math.huge
for _, shelf in pairs(Shelves:GetChildren()) do
if shelf:IsA(“Model”) and shelf.PrimaryPart ~= nil and Hibachi.PrimaryPart ~= nil then
local distance = (Hibachi.PrimaryPart.Position - shelf.PrimaryPart.Position).Magnitude
if distance < closestDistance then
closestShelf = shelf
closestDistance = distance
end
end
warn(closestShelf, closestDistance)
end
return closestShelf
end

local function selectCallback(player:Player, dish:string, …)
warn(player, dish, …)

–proximity.Enabled = false Multiplayer fix
local playerCharacter = player.Character
local HumanoidRootPart = playerCharacter:FindFirstChild(“HumanoidRootPart”)

local Humanoid = playerCharacter:FindFirstChildOfClass(“Humanoid”)
local Animator:Animator = Humanoid:WaitForChild(“Animator”)

playerCharacter.PrimaryPart.Anchored = true
playerCharacter:PivotTo(teleportPart:GetPivot() * CFrame.new(0, 2.9, 0))

– play animation
local OilPourAnimation = ReplicatedStorage.Animations.OilPour
local animationTrack = Animator:LoadAnimation(OilPourAnimation)
animationTrack:Play(1, 1, 0.55)

– Start fire effect
task.wait(3)
FirePart.Parent.CFrame = originalFirePartCFrame
FirePart.Enabled = true
local FireMovement = TweenService:Create(FirePart.Parent, TweenInfo.new(2), {CFrame = FireGoal.CFrame})
FireMovement:Play()
task.wait(2)
playerCharacter.PrimaryPart.Anchored = false

– find a random shelf and create that beam effect
local shelvesObject = hibachi.ConnectedShelves.Value
local TargetShelf = findClosestShelf(hibachi, shelvesObject)
–local TargetShelf = shelvesObject.Shelf
–local TargetShelves = shelvesObject:GetChildren()
–local TargetShelf = TargetShelves[math.random(1, #TargetShelves)]

local clonedGotoBeam = ReplicatedStorage:WaitForChild(“GotoBeam”):Clone()
clonedGotoBeam.Parent = HumanoidRootPart

if HumanoidRootPart ~= nil and TargetShelf.PrimaryPart ~= nil then
warn(“attaching beam object”)

  local attachment0 = Instance.new("Attachment", playerCharacter.PrimaryPart)
  attachment0.Name = "Attachment0"
  
  local clonedGotoBeam = ReplicatedStorage:WaitForChild("GotoBeam"):Clone()
  clonedGotoBeam.Parent = playerCharacter.PrimaryPart
  clonedGotoBeam.Enabled = true
  
  local attachment1 = Instance.new("Attachment", TargetShelf.PrimaryPart)
  attachment1.Name = "Attachment1"

  clonedGotoBeam.Attachment0 = attachment1
  clonedGotoBeam.Attachment1 = attachment0
  
  connections["clonedGotoBeam"] = clonedGotoBeam;
  connections["attachment0"] = attachment0;
  connections["attachment1"] = attachment1;
  
  -- skipping that
  local shelfProximity:ProximityPrompt = TargetShelf.PrimaryPart:WaitForChild("ProximityPrompt")
  shelfProximity.Enabled = true
  lastShelfProximity = shelfProximity
  --warn(shelfProximity:GetFullName())
  
  local chosenGear = ReplicatedStorage.FoodItems[dish]:Clone()
  
  -- add this to the connection list instead
  
  connections["shelfProximity"] = shelfProximity.Triggered:Connect(function(player)
  	if playerLastInteraction == player then
  		chosenGear.Parent = player.Backpack
  		shelfProximity.Enabled = false
  		connections["shelfProximity"]:Disconnect()
  		
  		-- remove stuff
  		connections["clonedGotoBeam"]:Destroy()
  		connections["attachment0"]:Destroy()
  		connections["attachment1"]:Destroy()
  	end
  end)
  
  -- create a new proximity prompt on the grill called "cook"

  proximity.Enabled = false -- disable the old proximity prompt
  local cookConnection = nil
  local cookProximity = Instance.new("ProximityPrompt", grill)
  cookProximity.ActionText = "Cook "..dish
  cookProximity.ObjectText = "Grill"
  
  table.insert(connections, cookProximity)
  
  cookConnection = cookProximity.Triggered:Connect(function(player)
  	-- we need to know if they have the tool out
  	-- otherwise throw an error message
  	local playerCharacter = player.Character
  	
  	if playerLastInteraction == player then
  		
  		local foundGear = playerCharacter:FindFirstChild(chosenGear.Name)
  		if foundGear ~= nil and foundGear == chosenGear then
  			-- player has the tool out, lets now cook 
  			warn("cooking food now")
  			
  			playerCharacter.PrimaryPart.Anchored = true
  			playerCharacter:PivotTo(teleportPart:GetPivot() * CFrame.new(0, 2.9, 0))
  			
  			-- now to clone that minigame and bind to get the result
  			
  			
  			local clonedMinigame = ReplicatedStorage.CookingMinigame:Clone()
  			local foundRemote = clonedMinigame:FindFirstChild("CompletedMinigame")
  			local PlayerGui = player:FindFirstChild("PlayerGui")
  			local foundGui = PlayerGui:FindFirstChild(clonedMinigame.Name)
  			if foundGui == nil then
  				clonedMinigame.Parent = PlayerGui
  			else
  				foundGui.Enabled = true
  			end
  			
  			
  			local remoteConnection = nil
  			remoteConnection = foundRemote.OnServerEvent:Once(function()
  				-- they at this point have destroyed the gui
  				-- now we are supposed to give them a new item
  				warn("won the game lol")
  				for _, gui in pairs(PlayerGui:GetChildren()) do
  					if gui.Name == "CookingGui" or "CookingMinigame" then
  						gui:Destroy()
  					end
  				end
  				
  				playerCharacter.PrimaryPart.Anchored = false
  				FirePart.Enabled = false
  				playerLastInteraction = nil
  				cookProximity:Destroy()
  				shelfProximity.Enabled = false
  				proximity.Enabled = true
  				
  				FirePart.Parent.CFrame = originalFirePartCFrame 
  				
  				playerLastInteraction = nil
  				connections[player]:Disconnect()
  				connections[player] = nil
  				
  				remoteConnection:Disconnect()
  				remoteConnection = nil
  				
  				
  			end)
  			
  			
  			
  			
  		end
  	end
  	
  	
  	
  end)

else
warn(“conditions not satisfied”)
end

–cleanupConnections()
end

local function GetFoodItems(): {}
local FoodItems = ReplicatedStorage.FoodItems
local result = {}

for _, item in pairs(FoodItems:GetChildren()) do
if item:IsA(“Tool”) and item:FindFirstChildOfClass(“StringValue”) then
local TextureId = item.Texture
result[item.Name] = TextureId.Value
end
end

return result
end

proximity.Triggered:Connect(function(player: Player)
warn(player.Name)
warn(connections)
– no one has used this before or has left
if not playerLastInteraction and player:IsInGroup(35411958) and player:GetRankInGroup(35411958) >= 3 then
warn(“is in group”)
local playerGui = player:FindFirstChild(“PlayerGui”)

  playerLastInteraction = player
  -- give the gui to the player
  
  -- remove any previous guis we dont want
  for _, item in pairs(playerGui:GetChildren()) do
  	if item.Name == CookingGui.Name or item.Name == CookingMini.Name then
  		item:Destroy()
  	end
  end
  
  if connections[player] == nil then

  	local clonedGui = CookingGui:Clone()
  	clonedGui.Parent = playerGui
  	clonedGui.Enabled = true
  	
  	local updateEvent = clonedGui:FindFirstChild("GetDishes")
  	local updateFoodConnection = nil
  	updateFoodConnection = updateEvent.OnServerEvent:Once(function(player)
  		warn("firing back to client response")
  		local foodItems = GetFoodItems()
  		updateEvent:FireClient(player, foodItems)
  		warn(foodItems)
  		
  		updateFoodConnection:Disconnect()
  		updateFoodConnection = nil
  	end)
  	
  	-- find our trigger and bind onserverevent
  	local selectEvent = clonedGui:FindFirstChild("SelectDish")
  	connections[player] = selectEvent.OnServerEvent:Once(selectCallback)
  end

else
– player walked away, task.delay this sep thread for timeout

end

end)

local ScreenGui = script.Parent
local Mainframe = ScreenGui.MainFrame
local ExitButton = Mainframe.Exit
local ItemList = Mainframe.ItemList

local connections = {}

local SelectDish = ScreenGui:WaitForChild(“SelectDish”)
local GetDishes = ScreenGui:WaitForChild(“GetDishes”)
local DestroyClient = game.ReplicatedStorage:WaitForChild(“RemoveClient”)

– send request to server to give us available food items and their textures
– loop through every given

local function cleanupConnections()
–warn(connections)
for key, connection in pairs(connections) do
if typeof(connection) == “RBXScriptConnection” and connection.Connected then
connection:Disconnect()
–warn(“is .Connected?”, connection.Connected)
connections[key] = nil
end
end
–warn(connections)
end

local function foodSelectCallback(foodName: string)
SelectDish:FireServer(foodName)
cleanupConnections()
warn(connections)
ScreenGui:Destroy()
end

local function clientEventCallback(itemlist:{})
– returned type is keyed dictionary
warn(“recived from server”, itemlist)
for key, value in pairs(itemlist) do

  local FoodItem = Mainframe.FoodItem:Clone()
  FoodItem.Parent = ItemList
  FoodItem.FoodName.Text = key
  FoodItem.FoodImage.Image = value
  FoodItem.Visible = true
  
  -- setup connections
  connections[FoodItem.FoodName.Text] = FoodItem.Select.MouseButton1Click:Connect(function()
  	foodSelectCallback(key)
  end)

end

end

warn(“firing server”)
GetDishes:FireServer()

–ItemList.FoodItem1.Select.MouseButton1Click:Connect(function()
– SelectDish:FireServer(“misoSoup”)
– ScreenGui:Destroy()
–end)

–ItemList.FoodItem1.Select.MouseEnter:Connect(function()
– ItemList.FoodItem1.Select.Roundify.ImageColor3 = Color3.fromRGB(135, 28, 28)
–end)

–ItemList.FoodItem1.Select.MouseLeave:Connect(function()
– ItemList.FoodItem1.Select.Roundify.ImageColor3 = Color3.fromRGB(212, 44, 44)
–end)

ExitButton.MouseButton1Click:Connect(function()
DestroyClient:FireServer()

local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui

ScreenGui:Destroy()
end)

GetDishes.OnClientEvent:Connect(clientEventCallback)

this would be the script of the CookingGui

Hey, I would love to help. :slightly_smiling_face:

This isn’t entirely correct, .Triggered in the ProximityPrompt does work on the client,:
Medal_dlkKhTBbfC

However, you can’t have a local script in them. This is because:

Local scripts can’t run in workspace they have to be in either StarterCharacterScripts, StarterPlayerScripts, ReplicatedFirst

For more information on that you can check this out: How To Check if a proximity prompt have been triggered in a local script? - Help and Feedback / Scripting Support - Developer Forum | Roblox

Does the issue happen every time or does it work the first time and then break after that? What are the errors in the console? Make sure PlayerGui exists first too before referencing it! The GUI might be inside StarterGui but not appearing on the player’s screen.

If the GUI does exist, it should be enabled from a LocalScript, not a ServerScript. It is hard to help debug this issue without knowing your exact setup! Let me know if you need more help and if you could provide more information that would be really helpful too.

1 Like

Just seen you have provided much more information! Please give me some time to go over it all :smile:

In the v3 version it worked normally. But since I already copied guis and setted everything I only copyied grills. But grills are connected to the GUi as usually normal. And when I did everything its not working. So it doesn’t work in the new game. Not at all it just doesn’t open gui or anything. The gui is enabled and it is in replicated storage. and it is active.

image

This condition is incorrect because "CookingMinigame" is always truthy.

if gui.Name == "CookingGui" or gui.Name == "CookingMinigame" then

CookingMiniGame is seperated and used for the mini-game cooking when is food received from shelves and then like cooking onto the grill.