what this script is meant to do is when the main menu frame is visible clickdetectors’s Max activation distance are set to infinity, or else their Max activation dist will be set to 32
script:
local mainMenuFrame = script.Parent
local function updateClickDetectors()
local distance = mainMenuFrame.Visible and math.huge or 32 -- Set distance based on visibility
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("ClickDetector") then
part.MaxActivationDistance = distance
end
end
end
updateClickDetectors()
mainMenuFrame:GetPropertyChangedSignal("Visible"):Connect(updateClickDetectors)
Is this a script or local script and where is it placed?
I added a few prints to help diagnose the issue, try this
print("hello world")
local mainMenuFrame = script.Parent
local x = 1
local function updateClickDetectors()
print("function called", x)
x += 1
local distance = mainMenuFrame.Visible and math.huge or 32 -- Set distance based on visibility
print("distance is", distance)
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("ClickDetector") then
part.MaxActivationDistance = distance
print("click detector found:", part.Name)
end
end
end
updateClickDetectors()
mainMenuFrame:GetPropertyChangedSignal("Visible"):Connect(updateClickDetectors)
Hold on, which gui’s visibility are you changing? And are you changing it via client or server? You are supposed to change the visibility of the frame in the player gui