Fridge Model GUI not showing up

Hi,

I made a fridge model that when interacted with through the proximity prompt it will show GUI with meals that the player can take. It should all work accordingly, but for some reason, the GUI is not showing up when the prompt is interacted with. The only output I get is that the player has interacted with the prompt.

Any help is much appreciated, thanks! :slight_smile:

Local Script in SPS

local ProximityPromptService = game:GetService("ProximityPromptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local promptEvent = ReplicatedStorage:WaitForChild("FridgeEvent")

local function onPromptTriggered(prompt)
	print("ProximityPrompt triggered:", prompt)

	promptEvent:FireServer(prompt)
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

Local Script in FridgeGui

local FridgeGui = script.Parent
local mainFrame = FridgeGui:WaitForChild("MainFrame")
local mealTemplate = mainFrame:WaitForChild("MealTemplate")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fridgeEvent = ReplicatedStorage:WaitForChild("FridgeEvent")

local meals = {
	{name = "Bacon and Eggs", model = game.ReplicatedStorage.Meals.BaconEggs},

}


local function setupMeals()
	for _, meal in ipairs(meals) do
		local mealFrame = mealTemplate:Clone()
		mealFrame.Parent = mainFrame
		mealFrame.Visible = true

		local viewportFrame = mealFrame:WaitForChild("ViewportFrame")
		local textLabel = mealFrame:WaitForChild("TextLabel")
		local takeButton = mealFrame:WaitForChild("TakeButton")

		-- Set up the viewport frame camera
		local camera = Instance.new("Camera")
		camera.Parent = viewportFrame
		viewportFrame.CurrentCamera = camera

		local mealModel = meal.model:Clone()
		mealModel.Parent = viewportFrame
		mealModel:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))

		textLabel.Text = meal.name


		takeButton.MouseButton1Click:Connect(function()
			local player = game.Players.LocalPlayer
			local backpack = player:FindFirstChild("Backpack")

			if backpack then
				meal.model:Clone().Parent = backpack
				FridgeGui.Enabled = false
				fridgeEvent:FireServer(meal.name)
			else
				warn("Backpack not found for player:", player.Name)
			end
		end)
	end
end


fridgeEvent.OnClientEvent:Connect(function()
	FridgeGui.Enabled = true
	setupMeals()
end)

FridgeGui.Enabled = false

Script in Replicated Storage

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local promptEvent = ReplicatedStorage:WaitForChild("FridgeEvent")

local function onPromptEventReceived(player, prompt)
	print("Prompt received from player:", player, "Prompt:", prompt)

end
promptEvent.OnServerEvent:Connect(onPromptEventReceived)

image

1 Like

Player.PlayerGui.YourGui and then do whatever you want with it or just take a gui from replicatedstorage or where you store it and put it into the player’s playergui. (doesnt matter if you do it on the server or not)

1 Like

Heres a simple script, theres nothing complex and you don’t need to overcomplicate it.

ProximityPrompt.Triggered:Connect(function(Player)
	Player.PlayerGui.YourGui.Enabled = true
end)
2 Likes