u can just assign a variable touched and break the loop when its true
local function epic ( )
local touched = false
part.touched:Connect(function ()
touched = true
print("returned")
return
end)
while wait(0.1) do
if touched == true then
break
end
print("epic")
end
end
Create a book value for if it is touched or not and once it’s touched set it to true. And then below that you check if it is true then break out of the function.