Detect Click Ended in a Click Detector

Is there a possible way to detect when a click ended in a click detector?
I tried to use text buttons inside a surface gui to detect a click end but moving your mouse away from the button when ending a mouse click will not be detected. i am currently stumped right now and answers would be appreciated!

wdym? ClickDetector.MouseClick will fire when the mouse clicks
do you want to hold the click detector?

i want the click detector to detect when a mouse click ended like MouseButton1Up from a text button

This can help you: ClickDetector

there is no such thing called MouseEnded for ClickDetector.
there is MouseHoverEnter and MouseHoverLeave.

I don’t think it is possible to detect when the click has ended (MouseButton1Up) using a click detector.
But there is still a way to do it.
Put this in a localscript:

local localPlayer = game.Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local cancelling -- variable used to check if player let go of click
mouse.Button1Down:Connect(function() -- when player starts holding click
    if mouse.Target == game.Workspace.Part then -- Part that has to be click detected
         cancelling = false
         while task.wait(0.2) do
             print("Player is holding Click on part")
             if cancelling then break end -- stops loop if player let go of click
    cancelling = true -- used to know when player let go of click
    if mouse.Target == game.Workspace.Part
          print("Player let go of click on part")
          -- do stuff to the part here when click is let go

Since this is a local script, you will have to use remote events to make something happen for everyone on the server. If you don’t use remote events, the change will only be visible to the client.

Here’s a local script I just wrote and tested.

local Game = game
local Workspace = workspace
local UserInputService = Game:GetService("UserInputService")
local Players = Game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local Part = Workspace:WaitForChild("Part")
local ClickDetector = Part:WaitForChild("ClickDetector")

local Connection

local function OnInputEnded(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.UserInputType.Name ~= "MouseButton1" then return end
	print("ClickDetector released.")

local function OnMouseClick(Player)
	if Player ~= LocalPlayer then return end --Prevent the function from executing for each client, only the client that triggered the 'ClickDetector'.
	if Connection and Connection.Connected then return end
	Connection = UserInputService.InputEnded:Connect(OnInputEnded)