I'm basically just trying to utilize these systems to reduce lag instead of copying and pasting the script every time I want a GUI to be opened. Everything about the script is working fine, except for the part where it's actually supposed to make the GUI visible on the player's screen lol. Here's the current script:
local ServerScriptService = game:GetService("ServerScriptService")
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local GUI = StarterGui:WaitForChild("Photos")
local Modules = ServerScriptService:WaitForChild("Modules")
local Engine = require(Modules:WaitForChild("Engine"))
local Connection = {}
function applyCode(Inst)
if not Inst:IsA("BasePart") then return end
Connection[Inst] = {}
local ProximityPrompt = Instance.new("ProximityPrompt")
ProximityPrompt.ActionText = Inst:GetAttribute("ActionText")
ProximityPrompt.ObjectText = Inst:GetAttribute("ObjectText")
ProximityPrompt.Parent = Inst
table.insert(Connection[Inst], ProximityPrompt.Triggered:Connect(function(Player)
if Inst:GetAttribute("Disabled") then return end
if not GUI:FindFirstChild(Inst:GetAttribute("GUIName")) then
return
end
GUI[Inst:GetAttribute("GUIName")].Enabled = true
end))
end
task.spawn(function()
local Tagged = CollectionService:GetTagged("LookAtPicture")
for count=1, #Tagged do
local Inst = Tagged[count]
task.spawn(function()
applyCode(Inst)
end)
end
end)
CollectionService:GetInstanceAddedSignal("LookAtPicture"):Connect(function(Inst)
task.spawn(function()
applyCode(Inst)
end)
end)
CollectionService:GetInstanceRemovedSignal("LookAtPicture"):Connect(function(Inst)
if not Connection[Inst] then return end
for count=1, #Connection[Inst] do
local con = Connection[count]
con:Disconnect()
end
Connection[Inst] = nil
end)
Any and all help is appreciated!

2 comments
is it this? if not GUI:FindFirstChild(Inst:GetAttribute("GUIName")) then return end try using print to see where the code ended
Tried that but it didn't help. Not getting any errors in Output either which is weird.