Frame disappears after click

ابا بعد ضغط يطلع صوت وبعد 2 ثانية يطلع فريم مطلوب وينحذف بعد ضعط مباشرة

لا هذه سكربت بس تعدل فيه local button = script.Parent local specificFrame = script.Parent.Parent.Parent:FindFirstChild("Frame2") -- Replace "Frame2" with the actual name of the frame local sound = game.ServerStorage:FindFirstChild("ButtonClick ound") -- Ensure this is the correct sound instance

button.MouseButton1Click:Connect(function() if specificFrame then specificFrame.Visible = true end if sound then sound:Play()

end
button:Destroy()

end)

Explanation and How to Use:

  1. Placement: Place this code inside a LocalScript. The ideal location is directly inside the TextButton or ImageButton that the user interacts with.
  2. Frame Name: Ensure the frame you want to show/hide is actually named "Frame2" and is located three levels above the button in the hierarchy (e.g., ScreenGui > ContainerFrame > AnotherContainer > Frame2 if the script is in ScreenGui > ContainerFrame > AnotherContainer > Button). Adjust the specificFrame line if the name or path is different.
  3. Sound Name: Make sure you have a Sound object named exactly "ButtonClick ound" inside game.ServerStorage. If the name is different (e.g., "ButtonClickSound"), update the soundObject line.
  4. Functionality:
    • When the user presses and holds the left mouse button on the button:
      • The sound "ButtonClick ound" plays immediately.
      • A 2-second timer starts.
    • If the user continues to hold the button down for the full 2 seconds:
      • The frame named "Frame2" becomes visible.
    • When the user releases the left mouse button (or moves the mouse off the button while holding it down):
      • The frame "Frame2" is hidden immediately (regardless of whether it was visible or if the 2 seconds had passed).
      • If the release happens before the 2 seconds are up, the frame will not be shown.
  5. No Destruction: The script no longer destroys the button (button:Destroy()).

Google

gemini

Gemini 2.5 Pro

Code editing is temporarily disabled
Loading...