Skip to content
TheChatArchiveThe Chat Archive
Amazon Novaamazon-nova-experimental-chat-05-14· AmazonHugging Face LMArena Human Preference 140K

make a script in lua roblox where if you press the proximity prompt in the button called…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    make a script in lua roblox where if you press the proximity prompt in the button called : GenButton ,every part in the folder called SiteLighting dissapears ,but if you press it again they reappear

  2. Amazon Nova Assistant

    Certainly! Below is a Lua script for Roblox that achieves the described functionality. This script should be placed in a ServerScript inside the GenButton.

    -- Get references to necessary objects
    local genButton = script.Parent -- Assuming the script is a child of GenButton
    local proximityPrompt = genButton:FindFirstChildOfClass("ProximityPrompt")
    local siteLightingFolder = workspace:FindFirstChild("SiteLighting")
    local parts = siteLightingFolder:GetChildren()
    local arePartsVisible = true -- Track the visibility state
    
    -- Function to toggle the visibility of parts
    local function togglePartsVisibility()
    	arePartsVisible = not arePartsVisible
    	for _, part in ipairs(parts) do
    		part.Visibility = arePartsVisible and Enum.PartVisibility.Visible or Enum.PartVisibility.Hidden
    	end
    end
    
    -- Function to handle the prompt triggered event
    local function onPromptTriggered(player)
    	-- Toggle the visibility of the parts in SiteLighting
    	togglePartsVisibility()
    end
    
    -- Connect the prompt triggered event to the handler function
    proximityPrompt.Triggered:Connect(onPromptTriggered)
    

    Explanation:

    1. References:

      • genButton: References the GenButton assuming the script is a child of GenButton.
      • proximityPrompt: Finds the ProximityPrompt within GenButton.
      • siteLightingFolder: Finds the SiteLighting folder in the workspace.
      • parts: Gets all the children (parts) inside the SiteLighting folder.
      • arePartsVisible: A boolean to track if the parts are currently visible.
    2. togglePartsVisibility Function:

      • Toggles the arePartsVisible boolean.
      • Iterates through each part in the parts table.
      • Sets the Visibility property of each part to Visible if arePartsVisible is true, otherwise sets it to Hidden

      Note: Roblox parts do not have a Visibility property. Instead you should use the Transparency property. If you want to hide the parts you should set the Transparency to 1 and to show them set it to 0. Here is the corrected code:

      -- Function to toggle the visibility of parts
      local function togglePartsVisibility()
      	arePartsVisible = not arePartsVisible
      	for _, part in ipairs(parts) do
      		part.Transparency = arePartsVisible and 0 or 1
      	end
      end
      
    3. onPromptTriggered Function:

      • This function is called whenever the ProximityPrompt is triggered.
      • It calls togglePartsVisibility to toggle the visibility of the parts.
    4. Event Connection:

      • Connects the Triggered event of the ProximityPrompt to the onPromptTriggered function.

    Notes:

    1. ProximityPrompt:
      • Ensure that the GenButton has a ProximityPrompt as a child.
    2. SiteLighting Folder:
      • Ensure that there is a folder named SiteLighting in the workspace and it contains the parts you want to toggle.
    3. Running on the Server:
      • This script should be a ServerScript because it manipulates game objects which should be handled on the server to prevent exploitation.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.