Part touching then waiting script

How do I make a script that checks if a part was touched by a player, then runs, then delays, and will not run again until that delay is over.

Generally when I make a script check if something is touched, then have it wait, it is still able to run again before the wait is over.

I think you mean using debounce:

local part = script.Parent -- Assuming the script is a child of the part
local debounce = false -- Variable to control the execution of the function

local function onTouch(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Check if the hit object is a player

    if player and not debounce then
        debounce = true -- Set debounce to true to prevent re-entry
        print(player.Name .. " touched the part!") -- Action to perform when touched

        -- Delay for 5 seconds
        wait(5)

        debounce = false -- Reset debounce after the delay
    end
end

part.Touched:Connect(onTouch) -- Connect the onTouch function to the Touched event of the part

In the example shown, debounce is used to prevent re-entry until a certain duration passed (in this case, 5 seconds). You may consider wrapping the action task.defer() if you want the cooldown to start before the action is finished (if it yields the script)